redirecting index.html
[clqr.git] / clqr-compiler.tex
blobfabf61a442b5270b4e207bd8986482c7f9c71944
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 its \VAR{name}, \retvalii{\T} in case
45 of warnings, and \retvaliii{\T} in case of failure.
48 \IT{(\FU*{COMPILE-FILE} \VAR{file}
49 \orGOO{\kwd{:output-file}\VAR{ out-path}\\
50 \kwd{:verbose} \VAR{ bool}\DF{\V{*compile-verbose*}}\\
51 \kwd{:print}\VAR{ bool}\DF{\V{*compile-print*}}\\
52 \kwd{:external-format} \VAR{
53 file-format}\DF{\kwd{:default}}}{\}})}
55 Write compiled contents of \VAR{path} to \VAR{out-path}.
56 Return \retval{true output path} or \retval{\NIL}, \retvalii{\T}
57 in case of warnings or errors, \retvaliii{\T} in case of warnings
58 or errors excluding style warnings.
61 \IT{\arrGOO{\V*{*compile-file-pathname*}\DF{\NIL}\\
62 \V*{*compile-file-truename*}\DF{\NIL}}{.}}
64 Input file used by \FU{compile-file}.
67 \IT{\arrGOO{\V*{*compile-print*}\\
68 \V*{*compile-verbose*}}{.}}
70 Defaults used in \FU{compile-file}.
73 \IT{(\FU*{COMPILE-FILE-PATHNAME} \Op{\kwd{:pathname} \VAR{path}})}
75 \retval{Pathname} \FU{COMPILE-FILE} writes to.
78 \IT{(\FU*{LOAD} \VAR{path}
79 \orGOO{\kwd{:verbose} \VAR{ bool}\DF{\V{*load-verbose*}}\\
80 \kwd{:print} \VAR{ bool}\DF{\V{*load-print*}}\\
81 \kwd{:if-does-not-exist} \VAR{ bool}\DF{\T}\\
82 \kwd{:external-format} \VAR{
83 file-format}\DF{\kwd{:default}}}{\}})}
85 Load source or compiled file. Return \retval{\T} if successful.
88 \IT{\arrGOO{\V*{*load-pathname*}\DF{\NIL}\\
89 \V*{*load-truename*}\DF{\NIL}}{.}}
91 Input file used by \FU{load}.
94 \IT{\arrGOO{\V*{*load-print*}\\
95 \V*{*load-verbose*}}{.}}
97 Defaults used in \FU{load}.
100 \IT{(\SO*{EVAL-WHEN} (%
101 \orGOO{\kwd{:compile-toplevel}\\
102 \kwd{:load-toplevel}\\
103 \kwd{:execute}}{\}}) \OPn{\VAR{form}})}
105 Evaluate \VAR{form}s returning \retval{values of last \VAR{form}} if
106 \SO{EVAL-WHEN} is in the top-level of a file being compiled, in the
107 top-level of a compiled file being loaded, or anywhere, respectively.
110 \IT{(\MC*{WITH-COMPILATION-UNIT} (\Op{\kwd{:override}
111 \VAR{bool}\DF{\NIL}}) \OPn{\VAR{form}})}
113 Return \retval{values of \VAR{form}s}. Warnings deferred by the
114 compiler until end of compilation are deferred until the end of
115 evaluation of \VAR{form}s.
118 \IT{(\SO*{LOAD-TIME-VALUE} \VAR{form}
119 \Op{\VAR{read-only}\DF{\NIL}})}
121 Evaluate \VAR{form} at compile time and treat \retval{its value} as
122 literal at run time.
125 \IT{(\SO*{QUOTE} \VAR{foo})}
127 Return \retval{unevaluated \VAR{foo}}.
130 \IT{(\GFU*{MAKE-LOAD-FORM} \VAR{foo} \Op{\VAR{environment}})}
132 Make \retval{one or two forms} enabling \FU{load} to construct
133 something equvalent to \VAR{foo}.
136 \IT{(\FU*{MAKE-LOAD-FORM-SAVING-SLOTS} \VAR{foo}
137 \orGOO{\kwd{:slot-names} \VAR{ slots}\\
138 \kwd{:environment} \VAR{ environment}}{\}})}
140 Make \retval{two forms} yielding something equvalent to \VAR{foo}
141 but preserving only \VAR{slots}.
144 \IT{\arrGOO{(\FU*{MACRO-FUNCTION} \VAR{ symbol }
145 \Op{\VAR{environment}})\\
146 (\FU*{COMPILER-MACRO-FUNCTION} \VAR{ name }
147 \Op{\VAR{environment}})}{.}}
149 Return specified \retval{macro function}, or \retval{compiler macro
150 function}, respectively, if any. Return \retval{\NIL}
151 otherwise. \kwd{setf}able.
154 \IT{(\FU*{EVAL} \VAR{form})}
156 Return \retval{values of \VAR{form}}.
159 \end{LIST}
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 \subsection{REPL and Debugging}
164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166 \begin{LIST}{1cm}
168 \IT{\arrGOO{\kwd*{+}\XOR\kwd*{++}\XOR\V*{+++}\\[1pt]
169 \kwd*{*}\XOR\kwd*{**}\XOR\V*{***}\\[1pt]
170 \kwd*{/}\XOR\kwd*{//}\XOR\V*{///}}{.}}
172 Last, penultimate, or antepenultimate form evaluated in the REPL, or
173 their respective primary values, or lists of their respective
174 values.
177 \IT{\kwd*{--}}
179 Form currently being evaluated by the REPL.
182 \IT{(\FU*{APROPOS} \VAR{string} \OPn{\VAR{package}})}
184 Print interned symbols containig \VAR{string}.
187 \IT{(\FU*{APROPOS-LIST} \VAR{string} \OPn{\VAR{package}})}
189 \retval{List of interned symbols} containig \VAR{string}.
192 \IT{(\FU*{DRIBBLE} \Op{\VAR{path}})}
194 Save a record of interactive session to file at \VAR{path}. Without
195 \VAR{path}, close that file.
198 \IT{(\FU*{ED} \Op{\VAR{file-or-function}\DF{\NIL}})}
200 Invoke editor if possible.
203 \IT{(\xorGOO{\FU*{MACROEXPAND-1}\\
204 \FU*{MACROEXPAND}}{\}} \VAR{form} \Op{\VAR{environment}})}
206 Return \retval{macro expansion}, once or entirely, respectively, of
207 \VAR{form} and \retvalii{\T} if \VAR{form} is a macro form.
208 Return \retval{\VAR{form}} and \retvalii{\NIL} otherwise.
211 \IT{\V*{*macroexpand-hook*}}
213 Function called by \FU{macroexpand-1} to generate macro expansions.
216 \IT{(\MC*{TRACE} \OPn{\VAR{function}})}
218 Cause \VAR{function}s to be traced. With no arguments,
219 return \retval{list of traced functions}.
222 \IT{(\MC*{UNTRACE} \OPn{\VAR{function}})}
224 Stop \VAR{function}s, or each currently traced function from being
225 traced.
228 \IT{\V*{*trace-output*}}
230 Stream \MC{trace} and \MC{time} print their output on.
233 \IT{(\MC*{STEP} \VAR{form})}
235 Step through evaluation of \VAR{form}. Return \retval{values of
236 \VAR{form}}.
239 \IT{(\MC*{TIME} \OPn{\VAR{form}})}
241 Evaluate \VAR{form}s and print timing information to
242 \V{*trace-output*}. Return \retval{values of \VAR{form}s}.
244 \IT{(\FU*{INSPECT} \VAR{foo})}
246 Interactively give information about \VAR{foo}.
249 \IT{(\FU*{DESCRIBE} \VAR{foo}
250 \Op{\VAR{stream}\DF{\V{*standard-output*}}})}
252 Send information about \VAR{foo} to \VAR{stream}.
255 \IT{(\GFU*{DESCRIBE-OBJECT} \VAR{foo} \Op{\VAR{stream}})}
257 Send information about \VAR{foo} to \VAR{stream}. Not to be
258 called by user.
261 \IT{(\FU*{DISASSEMBLE} \VAR{function})}
263 Send disassembled representation of \VAR{function} to
264 \V{*standard-output*}. Return \retval{\NIL}.
267 \end{LIST}
270 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271 \subsection{Declarations}
272 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273 \begin{LIST}{1cm}
275 \IT{\arrGOO{(\FU*{PROCLAIM} \VAR{ decl})\\
276 (\MC*{DECLAIM } \OPn{\NEV{\VAR{decl}}})}{.}}
278 Globally make declaration(s) \VAR{decl}. \VAR{decl} can be:
279 \kwd{declaration},
280 \kwd{type},
281 \kwd{ftype},
282 \kwd{inline},
283 \kwd{notinline},
284 \kwd{optimize}, or
285 \kwd{special}.
286 See below.
289 \IT{(\kwd*{DECLARE} \OPn{\NEV{\VAR{decl}}})}
291 Inside certain forms, locally make declarations \VAR{decl}. \VAR{decl} can be:
292 \kwd{dynamic-extent},
293 \kwd{type},
294 \kwd{ftype},
295 \kwd{ignorable},
296 \kwd{ignore},
297 \kwd{inline},
298 \kwd{notinline},
299 \kwd{optimize}, or
300 \kwd{special}.
301 See below.
304 \begin{LIST}{.5cm}
306 \IT{(\kwd*{DECLARATION} \OPn{foo})}
308 Make \VAR{foo}s names of declarations.
311 \IT{(\kwd*{DYNAMIC-EXTENT} \OPn{\VAR{var}} \OPn{(\kwd{function}
312 \VAR{fu})})}
314 Declare objects referred to by \VAR{var}s or \VAR{fu}s to have
315 dynamic extent.
319 \IT{\arrGOO{(\kwd*{TYPE} \VAR{ type} \OPn{\VAR{ variable}})\\
320 (\kwd*{FTYPE} \VAR{ type} \OPn{\VAR{ function}})}{.}}
322 Declare \VAR{variable} or \VAR{function} to be of \VAR{type}.
325 \IT{(\xorGOO{\kwd*{IGNORE}\\
326 \kwd*{IGNORABLE}}{\}}\xorGOO{%
327 \VAR{var}\\
328 (\kwd{function} \VAR{ function})}{\}^{\!\!*}})}
330 Suppress warnings about used/unused bindings.
333 \IT{\arrGOO{(\kwd*{INLINE} \OPn{\VAR{ function}})\\
334 (\kwd*{NOTINLINE} \OPn{\VAR{ function}})}{.}}
336 Tell compiler to integrate/not to integrate, respectively, called
337 \VAR{function}s into the calling routine.
340 \IT{(\kwd*{OPTIMIZE} \orGOO{%
341 \kwd*{COMPILATION-SPEED}\XOR(\kwd*{COMPILATION-SPEED}\VAR{ n})\\
342 \kwd*{DEBUG}\XOR(\kwd*{DEBUG}\VAR{ n})\\
343 \kwd*{SAFETY}\XOR(\kwd*{SAFETY}\VAR{ n})\\
344 \kwd*{SPACE}\XOR(\kwd*{SPACE}\VAR{ n})\\
345 \kwd*{SPEED}\XOR(\kwd*{SPEED}\VAR{ n})}{\}})}
347 Tell compiler how to optimize. $n=0$ means unimportant, $n=1$ is
348 neutral, $n=3$ means important.
351 \IT{(\kwd*{SPECIAL} \OPn{\VAR{var}})}
353 Declare \VAR{var}s being dynamic.
356 \end{LIST}
357 \end{LIST}