When the predicates discussed in this section are invoked, file specifications are treated as relative to the current working directory. While loading code, however, file specifications are treated as relative to the directory containing the file being read in. This has the effect that if one of these predicates is invoked recursively, the file specification of the recursive load is relative to the directory of the enclosing load. See Load Intro, for an introduction to these predicates.
Directives will be executed in order of occurrence. Be aware of
the rules governing relative file specifications, as they could
have an effect on the semantics of directives. Only the
first solution of directives is produced, and variable
bindings are not displayed. Directives that fail or raise
exceptions give rise to warning or error messages, but do not terminate
the load. However, these warning or error messages can be
intercepted by the hook
user:portray_message/2, which can
abort/0 to terminate the load, if that is the desired
Predicates loading source code are affected by the
character-conversion mapping, cf.
see Term I/O.
Most of the predicates listed below take an argument Files, which is a single file specification or a list of file specifications. Source, object and QL files usually end with a `.pl', `.po' and `.ql' suffix respectively. These suffixes are optional. Each file specification may optionally be prefixed by a module name. The module name specifies where to import the exported predicates of a module-file, or where to store the predicates of a non-module-file. The module is created if it doesn't exist already.
absolute_file_name/3 (see Stream Pred) is used for resolving
the file specifications. The file specification
is reserved and denotes the standard input stream.
These predicates are available in runtime systems with the following limitations:
single_var_warningshave no effect.
informationalProlog flag is off by default, suppressing informational messages.
use_module/3, which also returns the name of the loaded module, or imports a set of predicates from an existing module. Options is a list of zero or more of the following:
true(the default) to always load, or
changedto load only if the file has not yet been loaded or if it has been modified since it was last loaded. A non-module-file is not considered to have been previously loaded if it was loaded into a different module. The file
useris never considered to have been previously loaded.
always(the default) to always load, or
compile_timeto load only if the goal is not in the scope of another
load_files/[1,2]directive occurring in a `.po' or `.ql' file.
The latter is intended for use when the file only defines
predicates that are needed for proper term or goal
expansion during compilation of other files.
sourceto load source files only,
objectto load object (`.po') files only,
ql(obsolescent) to load `.ql' files only, or
latest(the default) to load any type of file, whichever is newest. If the file is
all(the default) to import all exported predicates if the file is a module-file, or a list of predicates to import.
compileto translate into compiled code,
consultto translate into static, interpreted code, or
assert_allto translate into dynamic, interpreted code.
The default is the compilation mode of any ancestor
load_files/[1,2] goal, or
compile otherwise. Note
that Mode has no effect when a `.po' or `.ql' file is
loaded, and that it is recommended to use
load_type(source), to ensure that the source
file will be loaded even in the presence of a `.po' or
ensure_loaded/1and imports the predicates in Imports. If any of these are not public, a warning is issued. Imports may also be set to the atom
allin which case all public predicates are imported. Same as
)with the addition that Module is unified with the loaded module.
use_module/2. The file containing the predicate definitions will be located in the following way:
user:library_directory/1are searched for a file INDEX.pl. This file is taken to contain relations between all exported predicates of the module-files in the library directory and its subdirectories. If an INDEX.pl is not found,
require/1will try to create one by loading the library package
)(see The Prolog Library).