continued work
[clqr.git] / clqr-compiler.tex
blob9fe89fbabcca4fe180fea4c02cdf84abb91c13ac
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{\kwd{*compile-verbose*}}\\
51 \kwd{:print}\VAR{ bool}\DF{\kwd{*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{\kwd{*load-verbose*}}\\
80 \kwd{:print} \VAR{ bool}\DF{\kwd{*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{(\SF*{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 \SF{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{(\kwd*{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{(\SF*{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{(\SF*{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 \kwd{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 (\kwd*{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}.
197 \IT{(\FU*{ED} \Op{\VAR{file-or-function}\DF{\NIL}})}
199 Invoke editor if possible.
202 \IT{(\xorGOO{\SF*{MACROEXPAND-1}\\
203 \SF*{MACROEXPAND}}{\}}\VAR{form} \Op{\VAR{environment}})}
205 Return \retval{macro expansion}, once or entirely, respectively, of
206 \VAR{form} and \retvalii{\T} if \VAR{form} is a macro form.
207 Return \retval{\VAR{form}} and \retvalii{\NIL} otherwise.
210 \IT{\V*{*macroexpand-hook*}}
212 Function called by \kwd{macroexpand-1} to generate macro expansions.
215 \IT{(\SF*{TRACE} \OPn{\VAR{function}})}
217 Cause \VAR{function}s to be traced. With no arguments,
218 return \retval{list of traced functions}.
221 \IT{(\SF*{UNTRACE} \OPn{\VAR{function}})}
223 Stop \VAR{function}s, or each currently traced function from being
224 traced.
227 \IT{\V*{*trace-output*}}
229 Stream \kwd{trace} and \kwd{time} print their output on.
232 \IT{(\SF*{STEP} \VAR{form})}
234 Step through evaluation of \VAR{form}. Return \retval{values of
235 \VAR{form}}.
238 \IT{(\SF*{TIME} \OPn{\VAR{form}})}
240 Evaluate \VAR{form}s and print timing information to
241 \V{*trace-output*}. Return \retval{values of \VAR{form}s}.
243 \IT{(\FU*{INSPECT} \VAR{foo})}
245 Interactively give information about \VAR{foo}.
248 \IT{(\FU*{DESCRIBE} \VAR{foo}
249 \Op{\VAR{stream}\DF{\kwd{*standard-output*}}})}
251 Send information about \VAR{foo} to \VAR{stream}.
254 \IT{(\GFU*{DESCRIBE-OBJECT} \VAR{foo} \Op{\VAR{stream}})}
256 Send information about \VAR{foo} to \VAR{stream}. Not to be
257 called by user.
260 \IT{(\FU*{DISASSEMBLE} \VAR{function})}
262 Send disassembled representation of \VAR{function} to
263 \kwd{*standard-output*}. Return \retval{\NIL}.
266 \end{LIST}
269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
270 \subsection{Declarations}
271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
272 \begin{LIST}{1cm}
274 \IT{\arrGOO{(\FU*{PROCLAIM} \VAR{ decl})\\
275 (\SF*{DECLAIM} \OPn{\VAR{ decl}})}{.}}
277 Globally make declaration(s) \VAR{decl}. \VAR{decl} can be:
278 \kwd{declaration},
279 \kwd{type},
280 \kwd{ftype},
281 \kwd{inline},
282 \kwd{notinline},
283 \kwd{optimize}, or
284 \kwd{special}.
285 See below.
288 \IT{(\SF*{DECLARE} \OPn{\VAR{decl}})}
290 Inside certain forms, locally make declarations \VAR{decl}. \VAR{decl} can be:
291 \kwd{dynamic-extent},
292 \kwd{type},
293 \kwd{ftype},
294 \kwd{ignorable},
295 \kwd{ignore},
296 \kwd{inline},
297 \kwd{notinline},
298 \kwd{optimize}, or
299 \kwd{special}.
300 See below.
303 \begin{LIST}{.5cm}
305 \IT{(\kwd*{DECLARATION} \OPn{foo})}
307 Make \VAR{foo}s names of declarations.
310 \IT{(\kwd*{DYNAMIC-EXTENT} \OPn{\VAR{var}} \OPn{(\kwd{function}
311 \VAR{fu})})}
313 Declare objects referred to by \VAR{var} or \VAR{fu} to have
314 dynamic extent.
318 \IT{\arrGOO{(\kwd*{TYPE} \VAR{ type} \OPn{\VAR{ variable}})\\
319 (\kwd*{FTYPE} \VAR{ type} \OPn{\VAR{ function}})}{.}}
321 Declare \VAR{variable} or \VAR{function} to be of \VAR{type}.
324 \IT{(\xorGOO{\kwd*{IGNORE}\\
325 \kwd*{IGNORABLE}}{\}}\xorGOO{%
326 \VAR{var}\\
327 (\kwd{function} \VAR{ function})}{\}^{\!\!*}})}
329 Suppress warnings about used/unused bindings.
332 \IT{\arrGOO{(\kwd*{INLINE} \OPn{\VAR{ function}})\\
333 (\kwd*{NOTINLINE} \OPn{\VAR{ function}})}{.}}
335 Tell compiler to integrate/not to integrate, respectively, called
336 \VAR{function}s into the calling routine.
339 \IT{(\kwd*{OPTIMIZE}\orGOO{%
340 \kwd*{COMPILATION-SPEED}\XOR(\kwd*{COMPILATION-SPEED}\VAR{ n})\\
341 \kwd*{DEBUG}\XOR(\kwd*{DEBUG}\VAR{ n})\\
342 \kwd*{SAFETY}\XOR(\kwd*{SAFETY}\VAR{ n})\\
343 \kwd*{SPACE}\XOR(\kwd*{SPACE}\VAR{ n})\\
344 \kwd*{SPEED}\XOR(\kwd*{SPEED}\VAR{ n})}{\}})}
346 Tell compiler how to optimize. $n=0$ means unimportant, $n=1$ is
347 neutral, $n=3$ means important.
350 \IT{(\kwd*{SPECIAL} \OPn{\VAR{var}})}
352 Declare \VAR{var}s being dynamic.
355 \end{LIST}
356 \end{LIST}