Compiling and loading

A program first needs be compiled before it is loaded into the system for execution. In order to compile a program in a file named fileName, type
      compile(fileName).
If the file name has the extension pl, then the extension can be omitted. The compiled byte-code will be stored in a new file with the same primary name and the extension out. In order to have the byte-code stored in a designated file, use
      compile(fileName,byteFileName).
For convenience, compile/1 accepts a list of file names.

The Prolog flag compiling instructs the compiler about the type of code to generate. The default value of the flag is compactcode, and two other possible values are debugcode and profilecode.

In order to load a compiled byte-code program, type

      load(fileName).

In order to compile and load a program in one step, use

      cl(fileName).
For convenience, both load/1 and cl/1 accept a list of file names.

Sometimes, users want to compile a program that is generated by another program. Users can save the program into a file, and then use compile or cl to compile the file. As file input and output take time, the following predicate is provided to compile a program without saving it into a file:

      compile_clauses(L).
where L must be a list of clauses to be compiled.

Neng-Fa Zhou 2013-01-25