load_files/[1,2]
load_files(
+Files)
load_files(
+Files, +Options)
[
+File|
+Files]
[]
Load the specified Prolog source and/or QOF files into memory. Subsumes all other load predicates.
.pl
or
.qof
extension may be omitted in a file specification.
if(
X)
X=true
X=changed
when(
X)
X=run_time
X=compile_time
X=both
load_type(
X)
X=compile
X=qof
X=latest
must_be_module(
X)
X=true
X=false
imports(
X)
X=all
X=
List
imports
is present, the option
must_be_module(true)
is enforced.
all_dynamic(
X)
X=true
X=false
all_dynamic option
has no effect when a
QOF file is loaded. Thus it is not normally useful to use
all_dynamic(true)
in conjunction with load_type(latest)
,
since the file will be loaded in dynamic mode only if the
source file is more recent than the QOF file.
silent(
X)
X=true
X=false
load_files/2
is the most general predicate for loading Prolog files.
Special cases of it are provided by the following predicates:
load_files(Files) :- load_files(Files, []). []. [File|Files] :- load_files([File|Files]). compile(Files) :- load_files(Files, [load_type(compile)]). consult(Files) :- /*consult equivalent to compile now*/ compile(Files). ensure_loaded(Files) :- load_files(Files, [if(changed)]). use_module(Files) :- load_files(Files, [if(changed), must_be_module(true)]). use_module(File, Imports) :- load_files(File, [if(changed), must_be_module(true), imports(Imports)]).
load_files/[1,2]
reads Prolog clauses, in source or in compiled (QOF)
form, and adds them to the Prolog database, after first deleting any previous
versions of the predicates they define. Clauses for a single predicate must
all be in the same file unless that predicate is declared to be multifile
.
If the file contains directives, that
is, terms with principal functor :-/1
or ?-/1
, then
these are executed as they are encountered.
Clauses and directives can be transformed as they are read from source
files (not from QOF), by providing a definition for
term_expansion/2
. This is true in both the development system and
QPC, but in order for this to work properly in QPC, your definition of
term_expansion/2
(and everything it calls) must be loaded into
QPC. This is accomplished with the when
option to
load_files/2
, or the -i
option to QPC.
A non-module source file can be loaded into any module by load_files/[2,3]
,
but the module of the predicates in a QOF-file is fixed at the time it is
created (by QPC, save_predicates/2
or save_program/[1,2]
). It is thus not
possible to qof save a predicate from say module foo
, and reloaded it
into module bar
, or QPC the non-module-file f1.pl
into f1.qof
, and then
load f1.qof
into module mod
(QPC assumes module user
when non-module
files are compiled separately). To avoid mistakes, load_files/[1,2]
loads
the corresponding source file, if such exists, whenever a non-module-file
is loaded into module other than user
. If no corresponding source file
exists, the QOF file is loaded; care should be taken in this case.
Initialization goals specified with initialization/1
are
executed after the load.
When load_files/[1,2]
is called from an embedded command in a
file being compiled by QPC, the load_type
and
if
options are ignored. The specfied files are compiled
from source to QOF, if the source is newer than the corresponding
QOF file. If the option when(compile_time)
is given, the file
is instead compiled into QPC memory, and no QOF is generated (see above).
When load_files/[1,2]
is called in a runtime system, the
all_dynamic
option will be automatically set to true because
the compiler is not available in runtime systems. This means that the
loaded code will run slower.
instantiation_error
type_error
domain_error
existence_error
fileerrors
flag is off
, the
predicate fails instead of raising this exception.
permission_error
fileerrors
flag is off
, the
predicate fails instead of raising this exception.
compile/1
, consult/1
,
dynamic/1
, ensure_loaded/1
, fileerrors/0
,
multifile/1
, no_style_check/1
, nofileerrors/0
,
prolog_load_context/2
, source_file/[1,2]
,
style_check/1
, term_expansion/2
, use_module/[1,2,3]
,
initialization/1
, volatile/1
.
ref-lod