Compiling and loading

A program needs be first compiled before being loaded into the system for execution. 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. 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 on what type of code to generate. The default value of the flag is compactcode, and two other possible values are debugcode and profilecode.

To load a compiled byte-code program, type

      load(fileName).
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, you want to compile a program generated by another program. You can save the program into a file and then use compile or cl to compile it. 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 2012-01-03