The autoloader is there to smoothen program development. It liberates the programmer from finding the library that defines some particular predicate and including the proper use_module/1,2 directive in the sources. This is even better at the toplevel, where just using maplist/3 is way more comfortable than first having to load library(apply). In addition, it reduces the startup time of applications by only loading the necessary bits.
Of course, there is also a price. One is that it becomes less obvious from where some predicate is loaded and thus whether you have the right definition. The second issue is that it is harder to create a stand-alone executable because this executable, without access to the development system, can no longer rely on autoloading.
This library provides autoload_all/0 and autoload_all/1 to autoload all
predicates that are referenced by the program. Now, this is in general
not possible in Prolog because the language allows for constructing
arbitrary goals and runtime and calling them (e.g.,
The implementation relies on code analysis of the bodies of all clauses and all initialization goals.
As of SWI-Prolog 8.1.22 the system provides autoload/1,2 directives that mitigate the possible ambiguity.
- autoload_all is det
- autoload_all(+Options) is det
- Force all necessary autoloading to be done now. This sets the
false, resolving explicit autoloading and then finds all undefined references to autoloadable predicates and load the library files that define these predicates.
false), report on the files loaded.
- Action defines what happens if the analysis finds a
definitely undefined predicate. One of
error. Default is
The following predicates are exported, but not or incorrectly documented.