The compiler can be called not only by the functions COMPILE,
COMPILE-FILE and DISASSEMBLE, but also by the declaration
(COMPILE).
COMPILE-FILECOMPILE-FILE compiles a file to a platform-independent
bytecode:
(COMPILE-FILEfilename&KEY:OUTPUT-FILE:LISTING:EXTERNAL-FORMAT((:WARNINGSCUSTOM:*COMPILE-WARNINGS*)CUSTOM:*COMPILE-WARNINGS*) ((:VERBOSE*COMPILE-VERBOSE*)*COMPILE-VERBOSE*) ((*COMPILE-PRINT*)*COMPILE-PRINT*))
Options for COMPILE-FILE
filename:OUTPUT-FILENIL or T or a pathname designator or an
output STREAM. The default is T.:LISTINGNIL or T or a pathname designator or an
output STREAM. The default is NIL.:EXTERNAL-FORMATEXT:ENCODING of the filename.
:WARNINGS:VERBOSE:PRINTThe variables CUSTOM:*COMPILE-WARNINGS*,
*COMPILE-VERBOSE*, *COMPILE-PRINT* provide defaults for the
:WARNINGS, :VERBOSE, :PRINT keyword arguments, respectively,
and are bound by COMPILE-FILE to the values of the arguments, i.e.,
these arguments are recursive.
For each input file (default file type: #P".lisp")
the following files are generated:
| File | When | Default file type | Contents |
|---|---|---|---|
| output file | only if :OUTPUT-FILE is not NIL | #P".fas" | can be loaded using the LOAD function |
| auxiliary output file | only if :OUTPUT-FILE is not NIL | #P".lib" | used by COMPILE-FILE when compiling a REQUIRE form referring
to the input file |
| listing file | only if :LISTING is not NIL | #P".lis" | disassembly of the output file |
| C output file | only if :OUTPUT-FILE is not NIL | #P".c" | “FFI”; this file is created only if the source contains “FFI” forms |
COMPILE-FILE-PATHNAMEThe default for the :OUTPUT-FILE argument is
T, which means #P".fas".
REQUIREThe function REQUIRE receives as the optional argument either
a PATHNAME or a LIST of PATHNAMEs: files to be LOADed
if the required module is not already present.
At compile time, (
forms are treated specially: REQUIRE #P"foo")CUSTOM:*LOAD-PATHS* is searched for
#P"foo.lisp" and #P"foo.lib".
If the latest such file is a #P".lisp", it is compiled;
otherwise the #P".lib" is loaded.
The #P".lib" is a “header” file which contains the
constant, variable, inline and macro definitions necessary for
compilation of the files that REQUIRE this file, but not the function
definitions and calls that are not necessary for that.
Thus it is not necessary to either enclose REQUIRE forms in
EVAL-WHEN or to load the required files in the makefiles: if you have
two files, #P"foo.lisp" and #P"bar.lisp", and the
latter requires the former, you can write in your Makefile:
all: foo.fas bar.fas foo.fas: foo.lisp clisp -c foo bar.fas: bar.lisp foo.fas clisp -c bar
instead of the more cumbersome (and slower, since #P".lib"s are
usually smaller and load faster that #P".fas"s):
bar.fas: bar.lisp foo.fas
clisp -i foo -c bar
Thus, you do not need to ( in order
to LOAD #P"foo")(.
If memory is tight, and if COMPILE-FILE #P"bar.lisp")#P"foo.lisp" contains only a few inline
functions, macros, constants or variables, this is a space and time
saver. If #P"foo.lisp" does a lot of initializations or side effects
when being loaded, this is important as well.
LOADLOAD accepts four additional keyword arguments :ECHO,
:COMPILING, :EXTRA-FILE-TYPES, and :OBSOLETE-ACTION.
(LOADfilename&KEY((:VERBOSE*LOAD-VERBOSE*)*LOAD-VERBOSE*) ((*LOAD-PRINT*)*LOAD-PRINT*) ((:ECHOCUSTOM:*LOAD-ECHO*)CUSTOM:*LOAD-ECHO*):IF-DOES-NOT-EXIST((:COMPILINGCUSTOM:*LOAD-COMPILING*)CUSTOM:*LOAD-COMPILING*):EXTRA-FILE-TYPES((:OBSOLETE-ACTIONCUSTOM:*LOAD-OBSOLETE-ACTION*)CUSTOM:*LOAD-OBSOLETE-ACTION*))
:VERBOSELOAD to emit a short message that a file is
being loaded. The default is *LOAD-VERBOSE*, which is initially
T, but can be changed by the -v option.
:PRINTLOAD to print the value of each form. The
default is *LOAD-PRINT*, which is initially NIL, but can be
changed by the -v option.:ECHO*STANDARD-OUTPUT* (normally to the screen). Should there be an
error in the file, you can see at one glance where it is.
The default is CUSTOM:*LOAD-ECHO*, which is
initially NIL, but can be changed by the -v option.
:COMPILINGCOMPILE-FILE - not written to a file.
The default is CUSTOM:*LOAD-COMPILING*, which is initially
NIL, but can be changed by the -C option.
:EXTRA-FILE-TYPESSpecifies the LIST of additional file types
considered for loading, in addition to CUSTOM:*SOURCE-FILE-TYPES*
(which is initially ("lisp" "lsp" "cl"))
and CUSTOM:*COMPILED-FILE-TYPES*
(which is initially ("fas")).
When filename does not specify a unique file
(e.g., filename is #P"foo" and both #P"foo.lisp"
and #P"foo.fas" are found in the
CUSTOM:*LOAD-PATHS*), then the newest file is loaded.
:OBSOLETE-ACTIONSpecifies the action to take when loading a
#P".fas" with a different bytecode version from the one
supported by this CLISP version. The possible actions are
If no file can be loaded and :IF-DOES-NOT-EXIST is non-NIL, an ERROR is SIGNALed.
The default is CUSTOM:*LOAD-OBSOLETE-ACTION*,
which is initially NIL.
The variables *LOAD-VERBOSE*, *LOAD-PRINT*,
CUSTOM:*LOAD-OBSOLETE-ACTION*, CUSTOM:*LOAD-COMPILING*, and CUSTOM:*LOAD-ECHO* are bound by LOAD when it
receives a corresponding keyword argument (:VERBOSE, :PRINT,
:OBSOLETE-ACTION, :COMPILING, and :ECHO), i.e., these arguments
are recursive, just like the arguments :WARNINGS, :VERBOSE, and
:PRINT for COMPILE-FILE.
When evaluation of a read form SIGNALs an ERROR, two RESTART-s are
available:
SKIPSTOPVariable CUSTOM:*LOAD-PATHS*. The variable CUSTOM:*LOAD-PATHS* contains a list of directories where the
files are looked for - in addition to the specified or current
directory - by LOAD, REQUIRE, COMPILE-FILE and
LOAD-LOGICAL-PATHNAME-TRANSLATIONS.
*FEATURES*The variable *FEATURES* initially contains the following symbols
Default *FEATURES*
:CLISP:ANSI-CL:COMMON-LISP:INTERPRETEREVAL is implemented:COMPILERCOMPILE and COMPILE-FILE are implemented
:SOCKETS:GENERIC-STREAMS:LOGICAL-PATHNAMES:FFI:GETTEXT:UNICODE:LOOPLOOP form is implemented
:CLOS:MOP:WIN32hardware = PC (clone) and operating system = Win32
(Windows 95/98/Me/NT/2000/XP):PC386hardware = PC (clone). It can be used as an
indicator for the mainstream hardware characteristics (such as the
existence of a graphics card with a non-graphics text mode,
or the presence of a keyboard with arrows and
Insert/Delete keys,
or an ISA/VLB/PCI bus) or software characteristics (such as the
Control+Alternate+Delete keyboard
combination).:UNIXoperating system = UNIX (in this case the hardware is irrelevant!)
:BEOSoperating system = BeOS (in that case :UNIX is also present)
:CYGWIN:UNIX is also present)
:MACOSoperating system = Mac OS X (in that case :UNIX is also present)
Each module should add the appropriate keyword, e.g.,
:SYSCALLS,
:DIRKEY,
:REGEXP,
:PCRE, etc.
EXT:FEATUREP
[CLRFI-1](EXT:FEATUREP provides run-time access to
the read-time conditionals form)#+ and #-.
form is a feature exression.
EXT:COMPILED-FILE-P
[CLRFI-2]( returns non-EXT:COMPILED-FILE-P filename)NIL
when the file filename exists, is readable, and appears to be a
CLISP-compiled #P".fas" file compatible with the currently used
bytecode format.
System definition facilities (such as asdf or defsystem) can
use it to determine whether the file needs to be recompiled.
| These notes document CLISP version 2.45 | Last modified: 2008-04-15 |