1
@node Compilation, Symbols, Special Forms and Functions, Top
4
@defun COMPILE (name &optional (definition nil))
7
If DEFINITION is NIL, NAME must be the name of a not-yet-compiled
8
function. In this case, COMPILE compiles the function, installs the compiled
9
function as the global function definition of NAME, and returns NAME.
10
If DEFINITION is non-NIL, it must be a lambda expression and NAME must be
11
a symbol. COMPILE compiles the lambda expression, installs the compiled
12
function as the function definition of NAME, and returns NAME.
13
There is only one exception for this: If NAME is NIL, then the compiled
14
function is not installed but is simply returned as the value of COMPILE.
15
In any case, COMPILE creates temporary files whose filenames are
16
"gazonk***". By default, i.e. if :LEAVE-GAZONK is not supplied or is
17
NIL, these files are automatically deleted after compilation.
22
@deffn {Special Form} EVAL-WHEN
27
(eval-when (@{situation@}*) @{form@}*)
30
A situation must be either COMPILE, LOAD, or EVAL. The interpreter evaluates
31
only when EVAL is specified. If COMPILE is specified, FORMs are evaluated
32
at compile time. If LOAD is specified, the compiler arranges so that FORMs
33
be evaluated when the compiled code is loaded.
38
@defun COMPILE-FILE (input-pathname &key output-file (load nil) (message-file nil) ;GCL specific keywords: system-p c-debug c-file h-file data-file)
42
Compiles the file specified by INPUT-PATHNAME and generates a fasl file
43
specified by OUTPUT-FILE. If the filetype is not specified in INPUT-PATHNAME,
44
then ".lsp" is used as the default file type for the source file. :LOAD
45
specifies whether to load the generated fasl file after compilation.
46
:MESSAGE-FILE specifies the log file for the compiler messages. It defaults to
47
the value of the variable COMPILER:*DEFAULT-MESSAGE-FILE*. A non-NIL value of
48
COMPILER::*COMPILE-PRINT* forces the compiler to indicate the form currently
49
being compiled. More keyword parameters are accepted, depending on the
50
version. Most versions of GCL can receive :O-FILE, :C-FILE, :H-FILE, and
51
:DATA-FILE keyword parameters, with which you can control the intermediate
52
files generated by the GCL compiler. Also :C-DEBUG will pass the -g flag to
56
By top level forms in a file, we mean the value of *top-level-forms* after
57
doing (TF form) for each form read from a file. We define TF as follows:
61
(setq x (macroexpand x))
63
(cond ((member (car x) '(progn eval-when))
65
(t (push x *top-level-forms*))))))
67
Among the common lisp special forms only DEFUN and DEFMACRO will cause actual
68
native machine code to be generated. The rest will be specially treated in an
69
init section of the .data file. This is done so that things like putprop,setq,
70
and many other forms would use up space which could not be usefully freed, if
71
we were to compile to native machine code. If you have other `ordinary' top
72
level forms which you need to have compiled fully to machine code you may
73
either set compiler::*COMPILE-ORDINARIES* to t, or put them inside a
75
(PROGN 'COMPILE ...forms-which-need-to-be-compiled)
77
The compiler will take each of them and make a temporary function which will be
78
compiled and invoked once. It is permissible to wrap a (PROGN 'COMPILE ..)
79
around the whole file. Currently this construction binds the
80
compiler::*COMPILE-ORDINARIES* flag to t. Setting this flag globally to a non
81
nil value to cause all top level forms to generate machine code. This might be
82
useful in a system such as PCL, where a number of top level lambda expressions
83
are given. Note that most common lisps will simply ignore the top level atom
84
'compile, since it has no side effects.
86
Defentry, clines, and defcfun also result in machine code being generated.
88
@unnumbered subsection Evaluation at Compile time
90
In GCL the eval-when behaviour was changed in order to allow
91
more efficient init code, and also to bring it into line with the resolution
92
passed by the X3j13 committee. Evaluation at compile time is controlled by
93
placing eval-when special forms in the code, or by the value of the variable
94
compiler::*eval-when-defaults* [default value :defaults]. If that variable
95
has value :defaults, then the following hold:
97
@w{Eval at Compile Type of Top Level Form}@*
101
defstructs, defvar, defparameter
103
defmacro, defconstant, defsetf, define-setf-method,
104
deftype, package ops, proclaim
110
By `partial' we mean (see the X3J13 Common Lisp document
111
(doc/compile-file-handling-of-top-level-forms) for more detail), that functions
112
will not be defined, values will not be set, but other miscellaneous compiler
113
properties will be set: eg properties to inline expand defstruct accessors and
114
testers, defstruct properties allowing subsequent defstructs to include this
115
one, any type hierarch information, special variable information will be set up.
123
As a side effect of compiling these two forms, foo would not have its function
124
cell changed. Neither would jo-a, although it would gain a property which
125
allows it to expand inline to a structure access. Thus if it had a previous
126
definition (as commonly happens from previously loading the file), this previous
127
definition would not be touched, and could well be inconsistent with the
128
compiler properties. Unfortunately this is what the CL standard says to do,
129
and I am just trying to follow it.
131
If you prefer a more intuitive scheme, of evaling all forms in the file, so
132
that there are no inconsistencies, (previous behaviour of AKCL) you may set
133
compiler::*eval-when-defaults* to '(compile eval load).
135
The variable compiler::*FASD-DATA* [default t] controls whether an ascii output
136
is used for the data section of the object file. The data section will be in
137
ascii if *fasd-data* is nil or if the system-p keyword is supplied to
138
compile-file and *fasd-data* is not eq to :system-p.
140
The old GCL variable *compile-time-too* has disappeared.
142
See OPTIMIZE on how to enable warnings of slow constructs.
167
@defun PROCLAIM (decl-spec)
170
Puts the declaration given by DECL-SPEC into effect globally. See the doc of
171
DECLARE for possible DECL-SPECs.
181
@defun PROVIDE (module-name)
184
Adds the specified module to the list of modules maintained in *MODULES*.
193
@defun COMPILED-FUNCTION-P (x)
196
Returns T if X is a compiled function; NIL otherwise.
206
List of symbols that name features of the current version of GCL.
207
These features are used to decide the read-time conditionalization facility
208
provided by '#+' and '#-' read macros. When the GCL reader encounters
210
#+ feature-description form
212
it reads FORM in the usual manner if FEATURE-DESCRIPTION is true. Otherwise,
213
the reader just skips FORM.
215
#- feature-description form
219
#- (not feature-description) form
221
A feature-description may be a symbol, which is true only when it is an
222
element of *FEATURES*. Or else, it must be one of the following:
224
(and feature-desciption-1 ... feature-desciption-n)
225
(or feature-desciption-1 ... feature-desciption-n)
226
(not feature-desciption)
228
The AND description is true only when all of its sub-descriptions are true.
229
The OR description is true only when at least one of its sub-descriptions is
230
true. The NOT description is true only when its sub-description is false.