next up previous index
Next: File Queries and Up: More about compilation Previous: Optimised Compilation

Compiling from a File

  The square brackets [...] or compile/1 are also used to compile Prolog source from a file. If the goal

compile(myfile).
or the short-hand notation:
[myfile].
is called, either as a query at the top level or within another goal, the system looks for the file myfile or for a file called myfile.pl and compiles it into the Prolog database. The short-hand notation may also be used to compile several files in sequence
[ file_1, file_2, ...   file_n ]
The compile/2 predicate may be used to compile a file or list of files into a module specified in the second argument.

It is a recommended programming practice to give the Prolog source programs the suffix .pl. It is not enforced by the system, but it simplifies managing the source programs. The compile/1 predicate automatically adds the suffix to the filename, so that it does not need to be specified; only if the literal filename can not be found, the system appends one of the valid suffixes and tries to find the resulting filename. The system's list of valid Prolog suffixes is in the global flag   prolog_suffix and can be examined and modified using get_flag/2 and set_flag/2. For example, to add the new suffix ``.pro'' use:

get_flag(prolog_suffix, Old), set_flag(prolog_suffix, [".pro"|Old]).


next up previous index
Next: File Queries and Up: More about compilation Previous: Optimised Compilation



Micha Meier
Mon Mar 4 12:11:45 MET 1996