[ ECLiPSe Predicate Database built-in.|Group Index| Full Index]

dump(+File)

Dump the object form of the source program in the file File into a file File.sd.

+File
Atom or string, or list of atoms or strings.

Description

This predicate is similar to compile/1 in that it reads the contents of the specified source file or files and compiles it to an internal form, however this internal form is not added to the Prolog database, but written into a dump file. The dump file can be loaded into the Prolog database with the compile/1 etc. predicates.

The atom or string File must be instantiated to a legitimate specification for an existing file except for the suffix. The predicate first checks whether the File exists and if so, File is taken as the literal file name. If File does not exist, the predicate tries to add to it the Prolog suffixes from the list specified in the Prolog flag prolog_suffix. The suffix .sd is not considered, because loading and dumping the same file does nothing useful. As soon as a file is found which exists, it is taken as the input file name. The default Prolog suffixes are .sd and .pl.

The name of the dump file is the same as that of the input file, but its suffix is replaced by (or added) .sd (ECLiPSe dump). The whole contents of the input file, including predicate definitions and queries, is stored into the dump file. The queries in the input file are processed in a special way, some of them are executed to allow correct reading of the input file, others are only transformed to the internal form and written into the dump file. The queries being executed are ','/2, ';'/2, op/3, local_op/3, set_flag/2, get_flag/2, define_global_macro/3, define_local_macro/3, ./2, compile/1, set_chtab/2, call/1, cprolog/1, bsi/1, sicstus/1 and quintus/1.

If compile/1 or ./2 (e.g. [File]) are encountered as queries in the input file, the query is replaced by dump/1 and the corresponding files are recursively dumped into their dump files. Unlike in the compile/1 predicate, relative pathnames are interpreted as starting in the current working directory, and not in the directory of the file being dumped (this prevents accidental creation of dump files in other directories).

If File is a list of file names, all files in the list are dumped into their corresponding dump files. It is not possible to dump several input files into one dump file, however it is possible to concatenate any number of dump files into one dump file, which has the same effect as concatenating all input files into one input file and dumping it.

Fail Conditions

None.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
File is not instantiated.
(5) Type error
File is instantiated, but not to an atom or string, or a list of atoms or strings.
(82)
The module in which the clauses should be dumped is locked.
(130)
The head of a clause is not an atom or a compound term.
(131)
A subgoal in the body of a clause is not an atom or a compound term.
(139)
This event is invoked at the end of each dumped file, by default it only reports the name of the input file.
(171)
File does not exist.

Examples


Success:
   [eclipse]: dump(country).
   country.pl dumped

   yes.
   % the .sd file is found first and loaded faster
   [eclipse]: [country, 'country.pl'].
   /home/eclipse/country.sd  loaded 31152 bytes in 0.27 seconds
   /home/eclipse/country.pl  compiled 31152 bytes in 0.53 seconds

Error:
   dump(F).               (Error 4).
   dump(file1/1).         (Error 5).
   dump(nofile).          (Error 171).


See Also

compile / 1, compile / 2, . / 2, compile_stream / 1, compile_term / 1