restore/1 predicates discussed in
the previous section are used for saving and restoring the entire Prolog
database. To save selected parts of a Prolog database, the predicates
save_predicates/2 are used.
To save everything that was loaded from the files src1.pl and src2.pl into file1.po (extensions optional), you would use:
| ?- save_files([src1,src2],file1).
Any module declarations, predicates, multifile clauses, or directives
encountered in those files will be saved. Source file information as
source_file/[1,2] for the relevant predicates and
modules is also saved.
To save the modules
into file2.po you would use:
| ?- save_modules([user,special],file2).
The module declarations, predicates, multifile clauses and initializations belonging to those modules will be saved. Source file information and embedded directives (except initializations) are not saved.
To just save certain predicates into file3.po you would use:
| ?- save_predicates([person/2,dept/4],file3).
This will only save the predicates specified. When the PO file is loaded the predicates will be loaded into the same module they were in originally.
Any PO file, however generated, can be loaded into Prolog with
| ?- load_files(file1).
| ?- [file1].
The information from each PO file loaded is incrementally added to the database. This means that definitions from later loads may replace definitions from previous loads.
load_files/[1,2] are used for compiling and
loading source files as well as PO files. If file1.po and
file1.pl both exist (and file1 does not),
load_files(file1) will load the source (‘.pl’) or the PO,
whichever is the most recent.
Refer to ref-lod for more
information on loading programs, and also to the reference page for