- Documentation
- Reference manual
- Built-in Predicates
- Loading Prolog source files
- load_files/1
- load_files/2
- consult/1
- ensure_loaded/1
- include/1
- require/1
- encoding/1
- make/0
- library_directory/1
- file_search_path/2
- expand_file_search_path/2
- prolog_file_type/2
- source_file/1
- source_file/2
- source_file_property/2
- exists_source/1
- exists_source/2
- unload_file/1
- prolog_load_context/2
- source_location/2
- at_halt/1
- cancel_halt/1
- initialization/1
- initialization/2
- initialize/0
- compiling/0
- Conditional compilation and program transformation
- Reloading files, active code and threads
- Quick load files
- Loading Prolog source files
- Built-in Predicates
- Packages
- Reference manual
The following options are currently supported:
- autoload(Bool)
- If
true
(defaultfalse
), indicate that this load is a demand load. This implies that, depending on the setting of the Prolog flag verbose_autoload, the load action is printed at levelinformational
orsilent
. See also print_message/2 and current_prolog_flag/2. - check_script(Bool)
- If
false
(defaulttrue
), do not check the first character to be
and skip the first line when found.#
- derived_from(File)
- Indicate that the loaded file is derived from File. Used by make/0 to time-check and load the original file rather than the derived file.
- dialect(+Dialect)
- Load Files with enhanced compatibility with the target Prolog system identified by Dialect. See expects_dialect/1 and section C for details.
- encoding(Encoding)
- Specify the way characters are encoded in the file. Default is taken from the Prolog flag encoding. See section 2.18.1 for details.
- expand(Bool)
- If
true
, run the filenames through expand_file_name/2 and load the returned files. Default isfalse
, except for consult/1 which is intended for interactive use. Flexible location of files is defined by file_search_path/2. - format(+Format)
- Used to specify the file format if data is loaded from a stream using
the
stream(Stream)
option. Default issource
, loading Prolog source text. Ifqlf
, load QLF data (see qcompile/1). - if(Condition)
- Load the file only if the specified condition is satisfied. The value
true
loads the file unconditionally,changed
loads the file if it was not loaded before or has been modified since it was loaded the last time,not_loaded
loads the file if it was not loaded before, andexists
is aschanged
, but the call load_files/2 silently if the file does not exist. - imports(Import)
- Specify what to import from the loaded module. The default for
use_module/1
is
all
. Import is passed from the second argument of use_module/2. Traditionally it is a list of predicate indicators to import. As part of the SWI-Prolog/YAP integration, we also support Pred as Name to import a predicate under another name. Finally, Import can be the termexcept(Exceptions)
, where Exceptions is a list of predicate indicators that specify predicates that are not imported or Pred as Name terms to denote renamed predicates. See also reexport/2 and use_module/2.bugName/Arity as NewName is currently implemented using a link clause. This harms efficiency and does not allow for querying the relation through predicate_property/2.If Import equals
all
, all operators are imported as well. Otherwise, operators are not imported. Operators can be imported selectively by adding termsop(Pri,Assoc,Name)
to the Import list. If such a term is encountered, all exported operators that unify with this term are imported. Typically, this construct will be used with all arguments unbound to import all operators or with only Name bound to import a particular operator. - modified(TimeStamp)
- Claim that the source was loaded at TimeStamp without
checking the source. This option is intended to be used together with
the
stream(Input)
option, for example after extracting the time from an HTTP server or database. - module(+Module)
- Load the indicated file into the given module, overruling the module
name specified in the
:- module(Name, ...)
directive. This currently serves two purposes: (1) allow loading two module files that specify the same module into the same process and force and (2): force loading source code in a specific module, even if the code provides its own module name. Experimental. - must_be_module(Bool)
- If
true
, raise an error if the file is not a module file. Used by use_module/[1,2]. - qcompile(Atom)
- How to deal with quick-load-file compilation by qcompile/1.
Values are:
- never
- Default. Do not use qcompile unless called explicitly.
- auto
- Use qcompile for all writeable files. See comment below.
- large
- Use qcompile if the file is‘large’. Currently, files larger than 100 Kbytes are considered large.
- part
- If load_files/2
appears in a directive of a file that is compiled into Quick Load Format
using qcompile/1,
the contents of the argument files are included in the
.qlf
file instead of the loading directive.
If this option is not present, it uses the value of the Prolog flag qcompile as default.
- optimise(+Boolean)
- Explicitly set the optimization for compiling this module. See optimise.
- redefine_module(+Action)
- Defines what to do if a file is loaded that provides a module that is
already loaded from another file. Action is one of
false
(default), which prints an error and refuses to load the file, ortrue
, which uses unload_file/1 on the old file and then proceeds loading the new file. Finally, there isask
, which starts interaction with the user.ask
is only provided if the streamuser_input
is associated with a terminal. - reexport(Bool)
- If
true
re-export the imported predicate. Used by reexport/1 and reexport/2. - register(Bool)
- If
false
, do not register the load location and options. This option is used by make/0 and load_hotfixes/1 to avoid polluting the load-context database. See source_file_property/2. - sandboxed(Bool)
- Load the file in sandboxed mode. This option controls the flag sandboxed_load.
The only meaningful value for
Bool is
true
. Usingfalse
while the Prolog flag is set totrue
raises a permission error. - scope_settings(Bool)
- Scope style_check/1
and expects_dialect/1
to the file and files loaded from the file after the directive. Default
is
true
. The system and user initialization files (see -f and -F) are loading withscope_settings(false)
. - silent(Bool)
- If
true
, load the file without printing a message. The specified value is the default for all files loaded as a result of loading the specified files. This option writes the Prolog flag verbose_load with the negation of Bool. - stream(Input)
- This SWI-Prolog extension compiles the data from the stream
Input. If this option is used, Files must be a
single atom which is used to identify the source location of the loaded
clauses as well as to remove all clauses if the data is reconsulted.
This option is added to allow compiling from non-file locations such as databases, the web, the user (see consult/1) or other servers. It can be combined with
format(qlf)
to load QLF data from a stream.
The load_files/2
predicate can be hooked to load other data or data from objects other
than files. See prolog_load_file/2
for a description and
library(http/http_load)
for an example. All hooks for load_files/2
are documented in section
B.10.