minor fixes from S to Z in index; \boxGOO changed; html changed
[clqr.git] / clqr-compiler.tex
blob73ad62cca146a013cdca821b1ecf18f15d480719
1 % Copyright (C) 2008 Bert Burgemeister
3 % Permission is granted to copy, distribute and/or modify this
4 % document under the terms of the GNU Free Documentation License,
5 % Version 1.2 or any later version published by the Free Software
6 % Foundation; with no Invariant Sections, no Front-Cover Texts and
7 % no Back-Cover Texts. For details see file COPYING.
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 \section{Compiler}
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 \subsection{Predicates}
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18 \begin{LIST}{1cm}
20 \IT{(\FU*{SPECIAL-OPERATOR-P} \VAR{foo})}
22 \retval{\T} if \VAR{foo} is a special operator.
25 \IT{(\FU*{COMPILED-FUNCTION-P} \VAR{foo})}
27 \retval{\T} if \VAR{foo} is of type \kwd{compiled-function}.
30 \end{LIST}
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34 \subsection{Compilation}
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 \begin{LIST}{1cm}
39 \IT{(\FU*{COMPILE}
40 \xorGOO{\NIL\VAR{ definition}\\
41 \xorGOO{\VAR{name}\\
42 (\kwd{setf } \VAR{name})}{\}}\text{ }\Op{\VAR{definition}}}{\}})}
44 Return \retval{compiled function} or replace \retval{\VAR{name}}'s
45 function definition with the compiled function. Return \retvalii{\T} in case
46 of warnings or errors, and \retvaliii{\T} in case of warnings
47 or errors excluding style warnings.
50 \IT{(\FU*{COMPILE-FILE} \VAR{file}
51 \orGOO{\kwd{:output-file}\VAR{ out-path}\\
52 \kwd{:verbose} \VAR{ bool}\DF{\V{\A compile-verbose\A}}\\
53 \kwd{:print}\VAR{ bool}\DF{\V{\A compile-print\A}}\\
54 \kwd{:external-format} \VAR{
55 file-format}\DF{\kwd{:default}}}{\}})}
57 Write compiled contents of \VAR{file} to \VAR{out-path}.
58 Return \retval{true output path} or \retval{\NIL}, \retvalii{\T}
59 in case of warnings or errors, \retvaliii{\T} in case of warnings
60 or errors excluding style warnings.
63 \IT{(\FU*{COMPILE-FILE-PATHNAME} \VAR{file} \Op{\kwd{:output-file}
64 \VAR{path}} \Op{\VAR{other-keyargs}})}
66 \retval{Pathname} \FU{COMPILE-FILE} writes to if invoked with the
67 same arguments.
70 \IT{(\FU*{LOAD} \VAR{path}
71 \orGOO{\kwd{:verbose} \VAR{ bool}\DF{\V{\A load-verbose\A}}\\
72 \kwd{:print} \VAR{ bool}\DF{\V{\A load-print\A}}\\
73 \kwd{:if-does-not-exist} \VAR{ bool}\DF{\T}\\
74 \kwd{:external-format} \VAR{
75 file-format}\DF{\kwd{:default}}}{\}})}
77 Load source file or compiled file into Lisp environment. Return
78 \retval{\T} if successful.
81 \IT{\arrGOO{\V{\A compile-file}\\
82 \V{\A load}}{\}}\kwd{-}%
83 \xorGOO{\kwd{pathname\A}\DF{\NIL}\\
84 \kwd{truename\A}\DF{\NIL}}{.}}
85 {\index{*COMPILE-FILE-PATHNAME*@\A COMPILE-FILE-PATHNAME\A}\index{*COMPILE-FILE-TRUENAME*@\A COMPILE-FILE-TRUENAME\A}\index{*LOAD-PATHNAME*@\A LOAD-PATHNAME\A}\index{*LOAD-TRUENAME*@\A LOAD-TRUENAME\A}
86 Input file used by \FU{compile-file}/by \FU{load}.
89 \IT{\arrGOO{\V{\A compile}\\
90 \V{\A load}}{\}}\kwd{-}%
91 \xorGOO{\kwd{print\A}\\
92 \kwd{verbose\A}}{.}}
93 {\index{*COMPILE-PRINT*@\A COMPILE-PRINT\A}\index{*COMPILE-VERBOSE*@\A COMPILE-VERBOSE\A}\index{*LOAD-PRINT*@\A LOAD-PRINT\A}\index{*LOAD-VERBOSE*@\A LOAD-VERBOSE\A}
94 Defaults used by \FU{compile-file}/by \FU{load}.
97 \IT{(\SO*{EVAL-WHEN} (%
98 \orGOO{\Goo{\kwd{:compile-toplevel}\XOR\kwd{compile}}\\
99 \Goo{\kwd{:load-toplevel}\XOR\kwd{load}}\\
100 \Goo{\kwd{:execute}\XOR\kwd{eval}}}{\}}) \PROGN{\VAR{form}})}
102 Return \retval{values of \VAR{form}s} if
103 \SO{EVAL-WHEN} is in the top-level of a file being compiled, in the
104 top-level of a compiled file being loaded, or anywhere,
105 respectively. Return \retval{\NIL} if \VAR{form}s are not
106 evaluated. (\kwd{compile}, \kwd{load} and \kwd{eval} deprecated.)
109 \IT{(\MC*{WITH-COMPILATION-UNIT} (\Op{\kwd{:override}
110 \VAR{bool}\DF{\NIL}}) \PROGN{\VAR{form}})}
112 Return \retval{values of \VAR{form}s}. Warnings deferred by the
113 compiler until end of compilation are deferred until the end of
114 evaluation of \VAR{form}s.
117 \IT{(\SO*{LOAD-TIME-VALUE} \VAR{form}
118 \Op{\NEV{\VAR{read-only}}\DF{\NIL}})}
120 Evaluate \VAR{form} at compile time and treat \retval{its value} as
121 literal at run time.
124 \IT{(\SO*{QUOTE} \NEV{\VAR{foo}})}
126 Return \retval{unevaluated \VAR{foo}}.
129 \IT{(\GFU*{MAKE-LOAD-FORM} \VAR{foo} \Op{\VAR{environment}})}
131 Its methods are to return a \retval{creation form} which on
132 evaluation at \FU{load} time returns an object equivalent to
133 \VAR{foo}, and an optional \retvalii{initialization form} which on
134 evaluation performs some initialization of the object.
137 \IT{(\FU*{MAKE-LOAD-FORM-SAVING-SLOTS} \VAR{foo}
138 \orGOO{\kwd{:slot-names} \VAR{ slots}\\
139 \kwd{:environment} \VAR{ environment}}{\}})}
141 Return a \retval{creation form} and an \retvalii{initialization
142 form} which on evaluation construct an object equivalent to
143 \VAR{foo} with \VAR{slots} initialized with the corresponding values
144 from \VAR{foo}.
147 \IT{\arrGOO{(\FU*{MACRO-FUNCTION} \VAR{ symbol }
148 \Op{\VAR{environment}})\\
149 (\FU*{COMPILER-MACRO-FUNCTION}\text{ }
150 \xorGOO{\VAR{name}\\
151 (\kwd{setf } \VAR{name})}{\}}\text{ }
152 \Op{\VAR{environment}})}{.}}
154 Return specified \retval{macro function}, or \retval{compiler mac\-ro
155 func\-tion}, respectively, if any. Return \retval{\NIL}
156 otherwise. \kwd{setf}able.
159 \IT{(\FU*{EVAL} \VAR{arg})}
161 Return \retval{values of value of \VAR{arg}} evaluated in global environment.
164 \end{LIST}
167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 \subsection[REPL~\&~Debug]{REPL and Debugging}
169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171 \begin{LIST}{1cm}
173 \IT{\arrGOO{\V*{+}\XOR\V*{++}\XOR\V*{+++}\\[1pt]
174 \V{\A}\text{ }\XOR\text{ }\V{\A\A}\text{ }\XOR\text{ }\V{\A\A\A}\\[1pt]
175 \V*{/}\text{ }\XOR\text{ }\V*{//}\text{ }\XOR\text{ }\V*{///}}{.}}
176 {\index{*@\A}\index{**@\A\A}\index{***@\A\A\A}
177 Last, penultimate, or antepenultimate \retval{form} evaluated in the REPL, or
178 their respective \retval{primary value}, or a \retval{list} of their respective
179 values.
182 \IT{\V*{--}}
184 \retval{Form} currently being evaluated by the REPL.
187 \IT{(\FU*{APROPOS} \VAR{string} \Op{\VAR{package}\DF{\NIL}})}
189 Print interned symbols containing \VAR{string}.
192 \IT{(\FU*{APROPOS-LIST} \VAR{string} \Op{\VAR{package}\DF{\NIL}})}
194 \retval{List of interned symbols} containing \VAR{string}.
197 \IT{(\FU*{DRIBBLE} \Op{\VAR{path}})}
199 Save a record of interactive session to file at \VAR{path}. Without
200 \VAR{path}, close that file.
203 \IT{(\FU*{ED} \Op{\VAR{file-or-function}\DF{\NIL}})}
205 Invoke editor if possible.
208 \IT{(\xorGOO{\FU*{MACROEXPAND-1}\\
209 \FU*{MACROEXPAND}}{\}} \VAR{form} \Op{\VAR{environment}\DF{\NIL}})}
211 Return \retval{macro expansion}, once or entirely, respectively, of
212 \VAR{form} and \retvalii{\T} if \VAR{form} was a macro form.
213 Return \retval{\VAR{form}} and \retvalii{\NIL} otherwise.
216 \IT{\V{\A macroexpand-hook\A}}
217 {\V{*MACROEXPAND-HOOK*@\A MACROEXPAND-HOOK\A}
218 Function of arguments expansion function, macro form, and
219 environment called by \FU{macroexpand-1} to generate macro
220 expansions.
223 \IT{(\MC*{TRACE} \xorGOO{\VAR{function}\\
224 (\kwd{setf } \VAR{function})}{\}^{\!\!*}})}
226 Cause \VAR{function}s to be traced. With no arguments,
227 return \retval{list of traced functions}.
230 \IT{(\MC*{UNTRACE} \xorGOO{\VAR{function}\\
231 (\kwd{setf } \VAR{function})}{\}^{\!\!*}})}
233 Stop \VAR{function}s, or each currently traced function, from being
234 traced.
237 \IT{\V{\A trace-output\A}}
238 {\index{*TRACE-OUTPUT*@\A TRACE-OUTPUT\A}
239 Stream \MC{trace} and \MC{time} print their output on.
242 \IT{(\MC*{STEP} \VAR{form})}
244 Step through evaluation of \VAR{form}. Return \retval{values of
245 \VAR{form}}.
248 \IT{(\FU*{BREAK} \Op{\VAR{control} \OPn{\VAR{arg}}})}
250 Jump directly into debugger; return \retval{\NIL}.
251 See p.\ \pageref{section:Format}, \FU{format}, for \VAR{control}
252 and \VAR{arg}s.
255 \IT{(\MC*{TIME} \VAR{form})}
257 Evaluate \VAR{form}s and print timing information to
258 \V{\A trace-output\A}. Return \retval{values of \VAR{form}}.
260 \IT{(\FU*{INSPECT} \VAR{foo})}
262 Interactively give information about \VAR{foo}.
265 \IT{(\FU*{DESCRIBE} \VAR{foo}
266 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
268 Send information about \VAR{foo} to \VAR{stream}.
271 \IT{(\GFU*{DESCRIBE-OBJECT} \VAR{foo} \Op{\DES{\VAR{stream}}})}
273 Send information about \VAR{foo} to \VAR{stream}. Not to be
274 called by user.
277 \IT{(\FU*{DISASSEMBLE} \VAR{function})}
279 Send disassembled representation of \VAR{function} to
280 \V{\A standard-output\A}. Return \retval{\NIL}.
283 \end{LIST}
286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
287 \subsection{Declarations}
288 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
289 \begin{LIST}{1cm}
291 \IT{\arrGOO{(\FU*{PROCLAIM} \VAR{ decl})\\
292 (\MC*{DECLAIM } \OPn{\NEV{\VAR{decl}}})}{.}}
294 Globally make declaration(s) \VAR{decl}. \VAR{decl} can be:
295 \kwd{declaration},
296 \kwd{type},
297 \kwd{ftype},
298 \kwd{inline},
299 \kwd{notinline},
300 \kwd{optimize}, or
301 \kwd{special}.
302 See below.
305 \IT{(\kwd*{DECLARE} \OPn{\NEV{\VAR{decl}}})}
307 Inside certain forms, locally make declarations \OPn{\VAR{decl}}. \VAR{decl} can be:
308 \kwd{dynamic-extent},
309 \kwd{type},
310 \kwd{ftype},
311 \kwd{ignorable},
312 \kwd{ignore},
313 \kwd{inline},
314 \kwd{notinline},
315 \kwd{optimize}, or
316 \kwd{special}.
317 See below.
320 \begin{LIST}{.5cm}
322 \IT{(\kwd*{DECLARATION} \OPn{foo})}
324 Make \VAR{foo}s names of declarations.
327 \IT{(\kwd*{DYNAMIC-EXTENT} \OPn{\VAR{variable}} \OPn{(\kwd{function}
328 \VAR{function})})}
330 Declare lifetime of \VAR{variable}s and/or \VAR{function}s to end
331 when control leaves enclosing block.
335 \IT{\arrGOO{(\Op{\kwd*{TYPE}} \VAR{ type} \OPn{\VAR{ variable}})\\
336 (\kwd*{FTYPE} \VAR{ type} \OPn{\VAR{ function}})}{.}}
338 Declare \VAR{variable}s or \VAR{function}s to be of \VAR{type}.
341 \IT{(\xorGOO{\kwd*{IGNORABLE}\\
342 \kwd*{IGNORE}}{\}}
343 \xorGOO{%
344 \VAR{var}\\
345 (\kwd{function} \VAR{ function})}{\}^{\!\!*}})}
347 Suppress warnings about used/unused bindings.
350 \IT{\arrGOO{(\kwd*{INLINE} \OPn{\VAR{ function}})\\
351 (\kwd*{NOTINLINE} \OPn{\VAR{ function}})}{.}}
353 Tell compiler to integrate/not to integrate, respectively, called
354 \VAR{function}s into the calling routine.
357 \IT{(\kwd*{OPTIMIZE} \orGOO{%
358 \kwd*{COMPILATION-SPEED}\XOR(\kwd*{COMPILATION-SPEED}\VAR{ n}\DF{\LIT{3}})\\
359 \kwd*{DEBUG}\XOR(\kwd*{DEBUG}\VAR{ n}\DF{\LIT{3}})\\
360 \kwd*{SAFETY}\XOR(\kwd*{SAFETY}\VAR{ n}\DF{\LIT{3}})\\
361 \kwd*{SPACE}\XOR(\kwd*{SPACE}\VAR{ n}\DF{\LIT{3}})\\
362 \kwd*{SPEED}\XOR(\kwd*{SPEED}\VAR{ n}\DF{\LIT{3}})}{\}})}
364 Tell compiler how to optimize. $n=0$ means unimportant, $n=1$ is
365 neutral, $n=3$ means important.
368 \IT{(\kwd*{SPECIAL} \OPn{\VAR{var}})}
370 Declare \VAR{var}s being dynamic.
373 \end{LIST}
374 \end{LIST}
379 % LocalWords: mac ro func tion
381 %%% Local Variables:
382 %%% mode: latex
383 %%% TeX-master: "clqr"
384 %%% End: