- 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
4.3.3 Quick load files
SWI-Prolog supports compilation of individual or multiple Prolog
source files into‘Quick Load Files’. A‘Quick Load File’(.qlf
file) stores the contents of the file in a precompiled format.
These files load considerably faster than source files and are normally more compact. They are machine-independent and may thus be loaded on any implementation of SWI-Prolog. Note, however, that clauses are stored as virtual machine instructions. Changes to the compiler will generally make old compiled files unusable.
Quick Load Files are created using qcompile/1.
They are loaded using
consult/1
or one of the other file-loading predicates described in
section 4.3. If consult/1
is given an explicit .pl
file, it will load the Prolog
source. When given a .qlf
file, it will load the file. When
no extension is specified, it will load the
.qlf
file when present and the .pl
file
otherwise.
- qcompile(:File)
- Takes a file specification as consult/1,
etc., and, in addition to the normal compilation, creates a Quick
Load File from File. The file extension of this file is
.qlf
. The basename of the Quick Load File is the same as the input file.If the file contains‘
:- consult(+File)
’,‘:- [+File]
’or‘:- load_files(+File, [qcompile(part), ...])
’statements, the referred files are compiled into the same.qlf
file. Other directives will be stored in the.qlf
file and executed in the same fashion as when loading the.pl
file.For term_expansion/2, the same rules as described in section 2.11 apply.
Conditional execution or optimisation may test the predicate compiling/0.
Source references (source_file/2) in the Quick Load File refer to the Prolog source file from which the compiled code originates.
- qcompile(:File, +Options)
- As qcompile/1,
but processes additional options as defined by
load_files/2. Options
are passed to load_files/2.
In addition the following options are processed:
- include(+Include)
- What to include into the QLF file. Currently accepts only a single
value: the atom
user
. When specified, files loaded indirectly from File that to not come from the Prolog library are included into the.qlf
file. This may be used to generate a single file from an application. The result is comparable to a save state (see qsave_program/2) with the folowing differences:- Only your application code is included. The Prolog libraries and boot files are not.
- Only Prolog code is included,
.qlf
files cannot include arbitrary resources. - The file can be loaded into a running Prolog process, while a saved state can only be loaded into a virgin Prolog virtual machine.