cosmetic change to download.php
[clqr.git] / clqr-compiler.tex
blob5ed2856a06a7355759f565ac13f64168bc322730
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\\
41 \VAR{name}}{\}}
42 \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{\arrGOO{\V*{\A compile-file-pathname\A}\DF{\NIL}\\
64 \V*{\A compile-file-truename\A}\DF{\NIL}}{.}}
66 Input file used by \FU{compile-file}.
69 \IT{\arrGOO{\V*{\A compile-print\A}\\
70 \V*{\A compile-verbose\A}}{.}}
72 Defaults used in \FU{compile-file}.
75 \IT{(\FU*{COMPILE-FILE-PATHNAME} \VAR{file} \Op{\kwd{:output-file}
76 \VAR{path}} \Op{\VAR{other-keyargs}})}
78 \retval{Pathname} \FU{COMPILE-FILE} writes to if invoked with the
79 same arguments.
82 \IT{(\FU*{LOAD} \VAR{path}
83 \orGOO{\kwd{:verbose} \VAR{ bool}\DF{\V{\A load-verbose\A}}\\
84 \kwd{:print} \VAR{ bool}\DF{\V{\A load-print\A}}\\
85 \kwd{:if-does-not-exist} \VAR{ bool}\DF{\T}\\
86 \kwd{:external-format} \VAR{
87 file-format}\DF{\kwd{:default}}}{\}})}
89 Load source file or compiled file into Lisp environment. Return
90 \retval{\T} if successful.
93 \IT{\arrGOO{\V*{\A load-pathname\A}\DF{\NIL}\\
94 \V*{\A load-truename\A}\DF{\NIL}}{.}}
96 Input file used by \FU{load}.
99 \IT{\arrGOO{\V*{\A load-print\A}\DF{\NIL}\\
100 \V*{\A load-verbose\A}}{.}}
102 Defaults used in \FU{load}.
105 \IT{(\SO*{EVAL-WHEN} (%
106 \orGOO{\Goo{\kwd{:compile-toplevel}\XOR\kwd{compile}}\\
107 \Goo{\kwd{:load-toplevel}\XOR\kwd{load}}\\
108 \Goo{\kwd{:execute}\XOR\kwd{eval}}}{\}}) \PROGN{\VAR{form}})}
110 Return \retval{values of \VAR{form}s} if
111 \SO{EVAL-WHEN} is in the top-level of a file being compiled, in the
112 top-level of a compiled file being loaded, or anywhere,
113 respectively. (\kwd{compile}, \kwd{load} and \kwd{eval} deprecated.)
116 \IT{(\MC*{WITH-COMPILATION-UNIT} (\Op{\kwd{:override}
117 \VAR{bool}\DF{\NIL}}) \PROGN{\VAR{form}})}
119 Return \retval{values of \VAR{form}s}. Warnings deferred by the
120 compiler until end of compilation are deferred until the end of
121 evaluation of \VAR{form}s.
124 \IT{(\SO*{LOAD-TIME-VALUE} \VAR{form}
125 \Op{\VAR{read-only}\DF{\NIL}})}
127 Evaluate \VAR{form} at compile time and treat \retval{its value} as
128 literal at run time.
131 \IT{(\SO*{QUOTE} \VAR{foo})}
133 Return \retval{unevaluated \VAR{foo}}.
136 \IT{(\GFU*{MAKE-LOAD-FORM} \VAR{foo} \Op{\VAR{environment}})}
138 Its methods are to return a \retval{creation form} which on
139 evaluation at \FU{load} time returns an object equivalent to
140 \VAR{foo}, and an optional \retvalii{initialization form} which on
141 evaluation performs some initialization of the object.
144 \IT{(\FU*{MAKE-LOAD-FORM-SAVING-SLOTS} \VAR{foo}
145 \orGOO{\kwd{:slot-names} \VAR{ slots}\\
146 \kwd{:environment} \VAR{ environment}}{\}})}
148 Return a \retval{creation form} and an \retvalii{initialization
149 form} which on evaluation construct an object equivalent to
150 \VAR{foo} with \VAR{slots} initialized with the corresponding values
151 from \VAR{foo}.
154 \IT{\arrGOO{(\FU*{MACRO-FUNCTION} \VAR{ symbol }
155 \Op{\VAR{environment}})\\
156 (\FU*{COMPILER-MACRO-FUNCTION} \VAR{ name }
157 \Op{\VAR{environment}})}{.}}
159 Return specified \retval{macro function}, or \retval{compiler mac\-ro
160 func\-tion}, respectively, if any. Return \retval{\NIL}
161 otherwise. \kwd{setf}able.
164 \IT{(\FU*{EVAL} \VAR{form})}
166 Return \retval{values of \VAR{form}}.
169 \end{LIST}
172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173 \subsection[REPL~\&~Debug]{REPL and Debugging}
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 \begin{LIST}{1cm}
178 \IT{\arrGOO{\V*{+}\XOR\V*{++}\XOR\V*{+++}\\[1pt]
179 \V*{\A}\text{ }\XOR\text{ }\V*{\A\A}\text{ }\XOR\text{ }\V*{\A\A\A}\\[1pt]
180 \V*{/}\text{ }\XOR\text{ }\V*{//}\text{ }\XOR\text{ }\V*{///}}{.}}
182 Last, penultimate, or antepenultimate \retval{form} evaluated in the REPL, or
183 their respective \retval{primary value}, or a \retval{list} of their respective
184 values.
187 \IT{\V*{--}}
189 \retval{Form} currently being evaluated by the REPL.
192 \IT{(\FU*{APROPOS} \VAR{string} \OPn{\VAR{package}})}
194 Print interned symbols containing \VAR{string}.
197 \IT{(\FU*{APROPOS-LIST} \VAR{string} \OPn{\VAR{package}})}
199 \retval{List of interned symbols} containing \VAR{string}.
202 \IT{(\FU*{DRIBBLE} \Op{\VAR{path}})}
204 Save a record of interactive session to file at \VAR{path}. Without
205 \VAR{path}, close that file.
208 \IT{(\FU*{ED} \Op{\VAR{file-or-function}\DF{\NIL}})}
210 Invoke editor if possible.
213 \IT{(\xorGOO{\FU*{MACROEXPAND-1}\\
214 \FU*{MACROEXPAND}}{\}} \VAR{form} \Op{\VAR{environment}})}
216 Return \retval{macro expansion}, once or entirely, respectively, of
217 \VAR{form} and \retvalii{\T} if \VAR{form} is a macro form.
218 Return \retval{\VAR{form}} and \retvalii{\NIL} otherwise.
221 \IT{\V*{\A macroexpand-hook\A}}
223 Function called by \FU{macroexpand-1} to generate macro expansions.
226 \IT{(\MC*{TRACE} \OPn{\VAR{function}})}
228 Cause \VAR{function}s to be traced. With no arguments,
229 return \retval{list of traced functions}.
232 \IT{(\MC*{UNTRACE} \OPn{\VAR{function}})}
234 Stop \VAR{function}s, or each currently traced function, from being
235 traced.
238 \IT{\V*{\A trace-output\A}}
240 Stream \MC{trace} and \MC{time} print their output on.
243 \IT{(\MC*{STEP} \VAR{form})}
245 Step through evaluation of \VAR{form}. Return \retval{values of
246 \VAR{form}}.
249 \IT{(\FU*{BREAK} \Op{\VAR{control} \OPn{\VAR{arg}}})}
251 Jump directly into debugger; return \retval{\NIL}.
252 See p.\ \pageref{section:Format}, \FU{format}, for \VAR{control}
253 and \VAR{arg}s.
256 \IT{(\MC*{TIME} \VAR{form})}
258 Evaluate \VAR{form}s and print timing information to
259 \V{\A trace-output\A}. Return \retval{values of \VAR{form}s}.
261 \IT{(\FU*{INSPECT} \VAR{foo})}
263 Interactively give information about \VAR{foo}.
266 \IT{(\FU*{DESCRIBE} \VAR{foo}
267 \Op{\DES{\VAR{stream}}\DF{\V{\A standard-output\A}}})}
269 Send information about \VAR{foo} to \VAR{stream}.
272 \IT{(\GFU*{DESCRIBE-OBJECT} \VAR{foo} \Op{\DES{\VAR{stream}}})}
274 Send information about \VAR{foo} to \VAR{stream}. Not to be
275 called by user.
278 \IT{(\FU*{DISASSEMBLE} \VAR{function})}
280 Send disassembled representation of \VAR{function} to
281 \V{\A standard-output\A}. Return \retval{\NIL}.
284 \end{LIST}
287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288 \subsection{Declarations}
289 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290 \begin{LIST}{1cm}
292 \IT{\arrGOO{(\FU*{PROCLAIM} \VAR{ decl})\\
293 (\MC*{DECLAIM } \OPn{\NEV{\VAR{decl}}})}{.}}
295 Globally make declaration(s) \VAR{decl}. \VAR{decl} can be:
296 \kwd{declaration},
297 \kwd{type},
298 \kwd{ftype},
299 \kwd{inline},
300 \kwd{notinline},
301 \kwd{optimize}, or
302 \kwd{special}.
303 See below.
306 \IT{(\kwd*{DECLARE} \OPn{\NEV{\VAR{decl}}})}
308 Inside certain forms, locally make declarations \VAR{decl}. \VAR{decl} can be:
309 \kwd{dynamic-extent},
310 \kwd{type},
311 \kwd{ftype},
312 \kwd{ignorable},
313 \kwd{ignore},
314 \kwd{inline},
315 \kwd{notinline},
316 \kwd{optimize}, or
317 \kwd{special}.
318 See below.
321 \begin{LIST}{.5cm}
323 \IT{(\kwd*{DECLARATION} \OPn{foo})}
325 Make \VAR{foo}s names of declarations.
328 \IT{(\kwd*{DYNAMIC-EXTENT} \OPn{\VAR{variable}} \OPn{(\kwd{function}
329 \VAR{function})})}
331 Declare lifetime of \VAR{variable}s and/or \VAR{function}s to end
332 when control leaves enclosing block.
336 \IT{\arrGOO{(\kwd*{TYPE} \VAR{ type} \OPn{\VAR{ variable}})\\
337 (\kwd*{FTYPE} \VAR{ type} \OPn{\VAR{ function}})}{.}}
339 Declare \VAR{variable}s or \VAR{function}s to be of \VAR{type}.
342 \IT{(\xorGOO{\kwd*{IGNORABLE}\\
343 \kwd*{IGNORE}}{\}}
344 \xorGOO{%
345 \VAR{var}\\
346 (\kwd{function} \VAR{ function})}{\}^{\!\!*}})}
348 Suppress warnings about used/unused bindings.
351 \IT{\arrGOO{(\kwd*{INLINE} \OPn{\VAR{ function}})\\
352 (\kwd*{NOTINLINE} \OPn{\VAR{ function}})}{.}}
354 Tell compiler to integrate/not to integrate, respectively, called
355 \VAR{function}s into the calling routine.
358 \IT{(\kwd*{OPTIMIZE} \orGOO{%
359 \kwd*{COMPILATION-SPEED}\XOR(\kwd*{COMPILATION-SPEED}\VAR{ n})\\
360 \kwd*{DEBUG}\XOR(\kwd*{DEBUG}\VAR{ n})\\
361 \kwd*{SAFETY}\XOR(\kwd*{SAFETY}\VAR{ n})\\
362 \kwd*{SPACE}\XOR(\kwd*{SPACE}\VAR{ n})\\
363 \kwd*{SPEED}\XOR(\kwd*{SPEED}\VAR{ n})}{\}})}
365 Tell compiler how to optimize. $n=0$ means unimportant, $n=1$ is
366 neutral, $n=3$ means important.
369 \IT{(\kwd*{SPECIAL} \OPn{\VAR{var}})}
371 Declare \VAR{var}s being dynamic.
374 \end{LIST}
375 \end{LIST}
380 % LocalWords: mac ro func tion