The module consult in directory lib provides several handy library predicates that can assert the contents of a file into XSB's database. The use of these predicates may be necessary when the code needs to be dynamic (so that it is retractable), or when it contains atoms whose length is more than 255 that cannot be handled by the XSB compiler.
Dynamically loaded files can be filtered through the XSB preprocessor. To do this, put the following in the source file:
:- compiler_options([xpp_on]).
Of course, the name compiler_options
might seem like a misnomer
here (since the file is not being compiled), but it is convenient to
use the same directive both for compiling and loading, in case the same
source file is used both ways.
Notice that this predicate can be used to load files of Datalog facts (since they will be in canonical format). This predicate is significantly faster than load_dyn/1 and should be used when speed is important. A file that is to be dynamically loaded often but not often modified by hand should be loaded with this predicate. Use predicate cvt_canonical/2 (see below) to convert a usual file to a format readable by this predicate.
As with load_dyn/1
, the source file can be filtered through the C
preprocessor. However, since all clauses in such a file must be in
canonical form, the compiler_options/1
directive should look as
follows:
:-(compiler_options('.'(xpp_on,[]))).