REDUCE

15.2 Compiling Files

It is best to compile files using pslcomp, a minimal version of PSL capable of compiling files. The successful compilation of a file should not depend upon optional modules which have been loaded. On some computer systems the names of the files to be compiled can be listed as command line arguments. When PSLCOMP is brought up the following banner is displayed.

Portable Standard Lisp Compiler
Usage: PSLCOMP source-file ...

If an error occurs, the message

⋆⋆⋆⋆⋆ Error during compilation of NAME

is printed and the compilation is aborted.

(compile-file FILE:string): {t, nil, abort} expr
This function is used to compile files. A binary file is created with the same name except that the file type is changed to b. Beware, it is possible to overwrite the source file if the operating system truncates file names (this can be avoided by using compile-file-aux, described below). If the file name is without a suffix then sl is assumed. This function will return t if the compilation was successful, abort if after an error was signalled the user aborted the compilation, or nil if the source file was not found. When the source file cannot be found the message
    ⋆⋆⋆⋆⋆ Unable to find source file for: FILE

will be printed. Prior to the compilation the message

    ----- Compiling SOURCE-FILE to BINARY-FILE

is displayed. In addition, one of the following two messages will be printed when compilation has stopped.

    ----- Compilation of NAME completed  
 
    ----- Compilation of NAME aborted

(compile-file-aux SOURCE:string BINARY:string):
{t, nil, abort} expr
Since this function is used by compile-file to compile files, most of the comments concerning compile-file apply to compile-file-aux. Although one application of compile-file may be used to compile a number of files, with this function only one file can be compiled. The advantage of using compile-file-aux is that the name of the binary file is given explicitly.

During the compilation of a file, if an atomic expression is read at the top level the

⋆⋆⋆ Warning: non-list form ignored: ATOM

will be displayed and the expression will be ignored. A list whose first element is not atomic is saved for insertion into the an initialization function which is added to the binary file by the compiler (its name is **fasl**initcode**). The processing of a list whose first element is an id depends in large part upon values found on the property list of the id. The EVAL flag will cause the expression to be evaluated, using the current binding of toploopeval*, and compiled. The expression is only evaluated, again using the current binding of toploopeval*, if the id is flagged IGNORE. All other expressions are compiled. Compilation will modify the environment, in particular, all macro definitions are installed. Note that although defflavor is a macro it does not create a macro definition. It will however modify the property list of the flavor name.

As expressions are processed a list of expressions is built. When a function definition is made an application of putd is added to the list. Other expressions which are intended to be evaluated at load time were also added. This sequence of instructions, which preserves the order in which expressions were read, is compiled as the body of the initialization function (named **fasl**initcode**).

15.2.1 Order of Functions for Compilation

Functions whose type is not expr must be defined before their use in a compiled function, since the type of a function affects how it’s application will be treated by the compiler. The application of a macro is replaced by the expansion of the macro. For functions whose type is fexpr it is necessary to gather the unevaluated arguments into a list. Calling a function which is an nexpr requires that the arguments be evaluated and gathered into a list. When the compiler cannot determine the type of a function, because it has not been defined, it assumes that the type of the function is expr. Note that it is not possible to define a recursive function, whose type is not expr, without first defining a dummy version.