Fix fresh-line description
[clqr.git] / clqr-control-structure.tex
blobbddb8635ea95b779a47c80af833468d534eb263b
1 % Copyright (C) 2008, 2009, 2010, 2011, 2012, 2014 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; with no Invariant Sections, no Front-Cover Texts and
6 % no Back-Cover Texts. For details see file COPYING.
9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 \section{Control Structure}
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 \subsection{Predicates}
15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
16 \begin{LIST}{1cm}
18 \IT{(\FU*{EQ} \VAR{foo bar})}
20 \retval{\T} if \VAR{foo} and \VAR{bar} are identical.
23 \IT{(\FU*{EQL} \VAR{foo bar})}
25 \retval{\T} if \VAR{foo} and \VAR{bar}
26 are identical, or the same \kwd{character}, or \kwd{number}s of the
27 same type and value.
30 \IT{(\FU*{EQUAL} \VAR{foo bar})}
32 \retval{\T} if \VAR{foo} and \VAR{bar}
33 are \FU{EQL}, or are equivalent \kwd{pathname}s, or are \kwd{cons}es with
34 \FU{equal} cars and cdrs, or are \kwd{string}s or \kwd{bit-vector}s with
35 \FU{eql} elements below their fill pointers.
38 \IT{(\FU*{EQUALP} \VAR{foo bar})}
40 \retval{\T} if \VAR{foo} and \VAR{bar} are identical; or are the
41 same \kwd{character} ignoring case; or are \kwd{number}s of the same
42 value ignoring type; or are equivalent \kwd{pathname}s; or are
43 \kwd{cons}es or \kwd{array}s of the same shape with \FU{equalp}
44 elements; or are structures of the same type with
45 \FU{equalp} elements; or are \kwd{hash-table}s of the same size
46 with the same \kwd{:test} function, the same keys in terms of
47 \kwd{:test} function, and \FU{equalp} elements.
50 \IT{(\FU*{NOT} \VAR{foo})\qquad\qquad\qquad}
52 \retval{\T} if \VAR{foo} is \NIL; \retval{\NIL} otherwise.
55 \IT{(\FU*{BOUNDP} \VAR{symbol})\qquad\qquad}
57 \retval{\T} if \VAR{symbol} is a special variable.
60 \IT{(\FU*{CONSTANTP} \VAR{foo} \Op{\VAR{environment}\DF{\NIL}})}
62 \retval{\T} if \VAR{foo} is a constant form.
65 \IT{(\FU*{FUNCTIONP} \VAR{foo})\qquad\qquad}
67 \retval{\T} if \VAR{foo} is of type \kwd{function}.
70 \IT{(\FU*{FBOUNDP} \xorGOO{\VAR{foo}\\
71 (\kwd{setf } \VAR{foo})}{\}})}
73 \retval{\T} if \VAR{foo} is a global function or macro.
77 \end{LIST}
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 \subsection{Variables}
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 \begin{LIST}{1cm}
86 \IT{(\xorGOO{%
87 \MC*{DEFCONSTANT}\\
88 \MC*{DEFPARAMETER}}{\}} \NEV{\VAR{foo}} \VAR{form}
89 \Op{\NEV{\VAR{doc}}})}
91 Assign value of \VAR{form} to global constant/dynamic variable \retval{\VAR{foo}}.
94 \IT{(\MC*{DEFVAR} \NEV{\VAR{foo}} \OP{\VAR{form}
95 \Op{\NEV{\VAR{doc}}}})}
97 Unless bound already, assign value of \VAR{form} to dynamic variable
98 \retval{\VAR{foo}}.
101 \IT{(\xorGOO{\MC*{SETF}\\
102 \MC*{PSETF}}{\}} \Goos{\VAR{place}
103 \VAR{form}})}
105 Set \VAR{place}s to primary values of \VAR{form}s. Return \retval{values
106 of last \VAR{form}}/\retval{\NIL}; work sequentially/in parallel, respectively.
109 \IT{(\xorGOO{\SO*{SETQ}\\
110 \MC*{PSETQ}}{\}} \Goos{\VAR{symbol}
111 \VAR{form}})}
113 Set \VAR{symbol}s to primary values of \VAR{form}s. Return \retval{value
114 of last \VAR{form}}/\retval{\NIL}; work sequentially/in parallel, respectively.
117 \IT{(\FU*{SET} \DES{\VAR{symbol}} \VAR{foo})}
119 Set \VAR{symbol}'s value cell to \retval{\VAR{foo}}. Deprecated.
122 \IT{(\MC*{MULTIPLE-VALUE-SETQ} \VAR{vars} \VAR{form})}
124 Set elements of \VAR{vars} to the values of
125 \VAR{form}. Return \retval{\VAR{form}'s primary value}.
128 \IT{(\MC*{SHIFTF} \RP{\DES{\VAR{place}}} \VAR{foo})}
130 Store value of \VAR{foo} in rightmost \VAR{place} shifting values of
131 \VAR{place}s left, returning \retval{first \VAR{place}}.
134 \IT{(\MC*{ROTATEF} \OPn{\DES{\VAR{place}}})}
136 Rotate values of \VAR{place}s left, old first becoming new last
137 \VAR{place}'s value. Return \retval{\NIL}.
140 \IT{(\FU*{MAKUNBOUND} \DES{\VAR{foo}})}
142 Delete special variable \retval{\VAR{foo}} if any.
145 \label{:property_lists}
146 \IT{\arrGOO{(\FU*{GET} \VAR{ symbol} \VAR{ key }
147 \OP{\VAR{default}\DF{\NIL}})\\
148 (\FU*{GETF} \VAR{ place} \VAR{ key }
149 \OP{\VAR{default}\DF{\NIL}})}{.}}
151 \retval{First entry \VAR{key}} from property list stored in
152 \VAR{symbol}/in \VAR{place}, respectively, or \retval{\VAR{default}} if
153 there is no \VAR{key}. \kwd{setf}able.
156 \IT{(\FU*{GET-PROPERTIES} \VAR{property-list} \VAR{keys})}
158 Return \retval{key} and \retvalii{value} of first entry from \VAR{property-list}
159 matching a key from \VAR{keys}, and \retvaliii{tail of
160 \VAR{property-list}} starting with that key. Return \retval{\NIL},
161 \retvalii{\NIL}, and \retvaliii{\NIL} if there was no matching key
162 in \VAR{property-list}.
165 \IT{\arrGOO{(\FU*{REMPROP } \DES{\VAR{symbol}} \VAR{ key})\\
166 (\MC*{REMF } \DES{\VAR{place}} \VAR{ key})}{.}}
168 Remove first entry \VAR{key} from property list stored in
169 \VAR{symbol}/in \VAR{place}, respectively. Return \retval{\T} if \VAR{key}
170 was there, or \retval{\NIL} otherwise.
173 \IT{(\SO*{PROGV} \VAR{symbols} \VAR{values} \PROGN{\VAR{form}})}
175 Evaluate \VAR{form}s with locally established dynamic bindings of
176 \VAR{symbols} to \VAR{values} or \NIL. Return \retval{values of
177 \VAR{form}s}.
180 \IT{(\xorGOO{%
181 \SO*{LET}\\
182 \SO*{LET\A}}{\}} (%
183 \orGOO{\VAR{name}\\
184 (\VAR{name }\Op{\VAR{value}\DF{\NIL}})}{\}^{\!\!*}})
185 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
186 \PROGN{\VAR{form}})}
188 Evaluate \VAR{form}s with \VAR{name}s lexically bound (in parallel or
189 sequentially, respectively) to \VAR{value}s. Return
190 \retval{values of \VAR{form}s}.
193 \IT{(\MC*{MULTIPLE-VALUE-BIND} (\OPn{\NEV{\VAR{var}}}) \VAR{values-form}
194 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{body-form}})}
196 Evaluate \VAR{body-form}s with \VAR{var}s lexically bound to the
197 return values of \VAR{values-form}. Return \retval{values of
198 \VAR{body-form}s}.
201 \IT{(\MC*{DESTRUCTURING-BIND} \VAR{destruct-$\lambda$} \VAR{bar}
202 \OPn{(\kwd{declare}
203 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
205 Evaluate \VAR{form}s with variables from tree
206 \VAR{destruct-$\lambda$} bound to corresponding elements of tree
207 \VAR{bar}, and return \retval{their
208 values}. \VAR{destruct-$\lambda$} resembles \VAR{macro-$\lambda$}
209 (section \ref{section:Macros}), but without any \kwd{\&environment}
210 clause.
213 \end{LIST}
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217 \subsection{Functions}
218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
219 \label{section:Functions}
221 \begin{flushleft}
222 Below, ordinary lambda list (\OPn{\VAR{ord-$\lambda$}}) has the form\\
223 % \VAR{var} referenced from DEFSTRUCT
224 (\OPn{\VAR{var}}
225 \OP{\kwd{\&optional} \xorGOO{%
226 \VAR{var}\\
227 (\VAR{var } \OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
228 \penalty-5
229 \Op{\kwd{\&rest} \VAR{var}}
230 \penalty-5
231 \OP{\kwd{\&key} \xorGOO{%
232 \VAR{var}\\
233 (\xorGOO{%
234 \VAR{var}\\
235 (\kwd{:}\VAR{key } \VAR{var})}{\}}
236 \text{ }\OP{\VAR{init}\DF{\NIL}\text{ }\Op{\VAR{supplied-p}}})}{\}^{\!\!*}}
237 \penalty-5
238 \Op{\kwd{\&allow-other-keys}}}
239 \penalty-5
240 \OP{\kwd{\&aux} \xorGOO{%
241 \VAR{var}\\
242 (\VAR{var } \Op{\VAR{init}\DF{\NIL}})}{\}^{\!\!*}}}).
243 \end{flushleft}
244 \VAR{supplied-p} is \T\ if there is a corresponding
245 argument. \VAR{init} forms can refer to any \VAR{init} and
246 \VAR{supplied-p} to their left.
248 \begin{LIST}{1cm}
250 \IT{(\xorGOO{\MC*{DEFUN }\xorGOO{\VAR{foo }(\VAR{\OPn{ord-$\lambda$}})\\
251 (\kwd{setf} \VAR{ foo})\text{ }(\VAR{new-value } \VAR{\OPn{ord-$\lambda$}})}{.}\\
252 \MC*{LAMBDA }(\VAR{\OPn{ord-$\lambda$}})}{\}}
253 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
254 \Op{\NEV{\VAR{doc}}}
255 \PROGN{\VAR{form}})}
257 Define a function named \retval{\VAR{foo}} or \retval{(\kwd{setf}
258 \VAR{foo})}, or an anonymous \retval{function}, respectively, which applies
259 \VAR{form}s to \VAR{ord-$\lambda$}s. For \MC{defun}, \VAR{form}s are
260 enclosed in an implicit \SO{block} named \VAR{foo}.
263 \IT{(\xorGOO{\SO*{FLET}\\
264 \SO*{LABELS}}{\}}
265 (\OPn{(\xorGOO{\VAR{foo }(\OPn{\VAR{ord-$\lambda$}})\\
266 (\kwd{setf} \VAR{ foo})\text{ }(\VAR{new-value }\OPn{\VAR{ord-$\lambda$}})}{\}}
267 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{local-decl}}})}
268 \Op{\NEV{\VAR{doc}}}
269 \PROGN{\VAR{local-form}})}) \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
270 \PROGN{\VAR{form}})}
272 Evaluate \VAR{form}s with
273 locally defined functions \VAR{foo}. Globally defined functions of
274 the same name are shadowed. Each \VAR{foo} is also the name of an
275 implicit \SO{block} around its corresponding \OPn{\VAR{local-form}}.
276 Only for \SO{LABELS}, functions \VAR{foo} are visible inside
277 \VAR{local-forms}. Return \retval{values of \VAR{form}s}.
280 \IT{(\SO*{FUNCTION} \xorGOO{%
281 \VAR{foo}\\
282 (\MC{lambda } \OPn{\VAR{form}})}{\}})}
284 Return lexically innermost \retval{function} named \VAR{foo} or a
285 lexical closure of the \retval{\MC{lambda} expression}.
288 \IT{(\FU*{APPLY} \xorGOO{\VAR{function}\\
289 (\kwd{setf } \VAR{function})}{\}} \OPn{\VAR{arg}} \VAR{args})}
291 \retval{Values of \VAR{function}} called with
292 \VAR{arg}s and the list elements of \VAR{args}. \kwd{setf}able if
293 \VAR{function} is one of \FU{aref}, \FU{bit}, and \FU{sbit}.
296 \IT{(\FU*{FUNCALL} \VAR{function} \OPn{arg})}
298 \retval{Values of \VAR{function}} called with \VAR{arg}s.
301 \IT{(\SO*{MULTIPLE-VALUE-CALL} \VAR{function} \OPn{\VAR{form}})}
303 Call \VAR{function} with all the values of each \VAR{form} as its
304 arguments. Return \retval{values returned by \VAR{function}}.
307 \IT{(\FU*{VALUES-LIST} \VAR{list})}
309 Return \retval{elements of \VAR{list}}.
312 \IT{(\FU*{VALUES} \OPn{\VAR{foo}})}
314 Return as multiple values the \retval{primary values} of the
315 \VAR{foo}s. \kwd{setf}able.
318 \IT{(\FU*{MULTIPLE-VALUE-LIST} \VAR{form})}
320 \retval{List of the values of \VAR{form}}.
323 \IT{(\MC*{NTH-VALUE} \VAR{n} \VAR{form})}
325 Zero-indexed \retval{\VAR{n}th return value} of \VAR{form}.
328 \IT{(\FU*{COMPLEMENT} \VAR{function})}
330 Return \retval{new function} with same arguments and same side effects
331 as \VAR{function}, but with complementary truth value.
334 \IT{(\FU*{CONSTANTLY} \VAR{foo})}
336 \retval{Function} of any number of arguments returning \VAR{foo}.
339 \IT{(\FU*{IDENTITY} \VAR{foo})}
341 Return \retval{\VAR{foo}}.
344 \IT{(\FU*{FUNCTION-LAMBDA-EXPRESSION} \VAR{function})}
346 If available, return \retval{lambda expression} of \VAR{function},
347 \retvalii{\NIL} if \VAR{function} was defined in an environment
348 without bindings, and \retvaliii{name} of \VAR{function}.
351 \IT{(\FU*{FDEFINITION} \xorGOO{\VAR{foo}\\
352 (\kwd{setf } \VAR{foo})}{\}})}
354 \retval{Definition} of global function \VAR{foo}. \kwd{setf}able.
357 \IT{(\FU*{FMAKUNBOUND} \VAR{foo})}
359 Remove global function or macro definition \retval{\VAR{foo}}.
362 \IT{\arrGOO{\CNS*{CALL-ARGUMENTS-LIMIT}\\
363 \CNS*{LAMBDA-PARAMETERS-LIMIT}}{.}}
365 Upper bound of the number of function arguments or lambda list
366 parameters, respectively; $\geq50$.
369 \IT{\CNS*{MULTIPLE-VALUES-LIMIT}}
371 Upper bound of the number of values a multiple value can have;
372 $\geq20$.
375 \end{LIST}
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379 \subsection{Macros}
380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
381 \label{section:Macros}
383 \begin{flushleft}
384 Below, macro lambda list (\OPn{\VAR{macro-$\lambda$}}) has the form of
385 either
386 \penalty-5
387 (\Op{\kwd{\&whole} \VAR{var}}
388 \penalty-5
389 \Op{\VAR{E}}
390 \penalty-5
391 \xorGOO{%
392 \VAR{var}\\
393 (\OPn{\VAR{macro-$\lambda$}})}{\}^{\!\!*}}
394 \penalty-5
395 \Op{\VAR{E}}
396 \penalty-5
397 \Op{\kwd{\&optional}
398 \xorGOO{%
399 \VAR{var}\\
400 (\xorGOO{%
401 \VAR{var}\\
402 (\OPn{\VAR{macro-$\lambda$}})}{\}}\text{ }
403 \OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
404 \penalty-5
405 \Op{\VAR{E}}
406 \penalty-5
407 \Op{%
408 \xorGOO{%
409 \kwd{\&rest}\\
410 \kwd{\&body}}{\}}
411 \xorGOO{%
412 \VAR{rest-var}\\
413 (\OPn{\VAR{macro-$\lambda$}})}{\}}}
414 \penalty-5
415 \Op{\VAR{E}}
416 \penalty-5
417 \OP{\kwd{\&key}
418 \xorGOO{%
419 \VAR{var}\\
420 (\xorGOO{%
421 \VAR{var}\\
422 (\kwd{:}\VAR{key } \xorGOO{%
423 \VAR{var}\\
424 (\OPn{\VAR{macro-$\lambda$}})}{\}})}{\}}
425 \text{ }\OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}
426 \Op{\VAR{E}}
427 \Op{\kwd{\&allow-other-keys}}}
428 \penalty-5
429 \Op{\kwd{\&aux}
430 \xorGOO{%
431 \VAR{var}\\
432 (\VAR{var } \Op{\VAR{init}\DF{\NIL}})}{\}^{\!\!*}}}
433 \penalty-5
434 \Op{\VAR{E}})
438 \penalty-5
439 (\Op{\kwd{\&whole}
440 \VAR{var}}
441 \penalty-5
442 \Op{\VAR{E}}
443 \penalty-5
444 \xorGOO{%
445 \VAR{var}\\
446 (\OPn{\VAR{macro-$\lambda$}})}{\}^{\!\!*}}
447 \penalty-5
448 \Op{\VAR{E}}
449 \penalty-5
450 \Op{\kwd{\&optional}
451 \xorGOO{%
452 \VAR{var}\\
453 (\xorGOO{%
454 \VAR{var}\\
455 (\OPn{\VAR{macro-$\lambda$}})}{\}}\text{ }
456 \OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
457 \penalty-5
458 \Op{\VAR{E}}
459 \kwd{.}
460 \VAR{rest-var}).
461 \penalty-5
462 \end{flushleft}
463 One toplevel \Op{\VAR{E}} may be replaced by \kwd{\&environment}
464 \VAR{var}. \VAR{supplied-p} is \T\ if there is a corresponding
465 argument. \VAR{init} forms can refer to any \VAR{init} and
466 \VAR{supplied-p} to their left.
468 \begin{LIST}{1cm}
470 \IT{(\xorGOO{\MC*{DEFMACRO}\\
471 \FU*{DEFINE-COMPILER-MACRO}}{\}}
472 \xorGOO{\VAR{foo}\\
473 (\kwd{setf } \VAR{foo})}{\}}
474 (\OPn{\VAR{macro-$\lambda$}})
475 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \Op{\NEV{\VAR{doc}}}
476 \PROGN{\VAR{form}})}
478 Define macro \retval{\VAR{foo}} which on evaluation as (\VAR{foo}
479 \VAR{tree}) applies expanded \VAR{form}s to arguments from
480 \VAR{tree}, which corresponds to \VAR{tree}-shaped
481 \VAR{macro-$\lambda$}s. \VAR{form}s are enclosed in an implicit
482 \SO{block} named \VAR{foo}.
485 \IT{(\MC*{DEFINE-SYMBOL-MACRO} \VAR{foo} \VAR{form})}
487 Define symbol macro \retval{\VAR{foo}} which on evaluation evaluates
488 expanded \VAR{form}.
491 \IT{(\SO*{MACROLET} (\OPn{(\VAR{foo} (\OPn{\VAR{macro-$\lambda$}})
492 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{local-decl}}})}
493 \Op{\NEV{\VAR{doc}}} \PROGN{\VAR{macro-form}})}) \OPn{(\kwd{declare}
494 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
496 Evaluate \retval{\VAR{form}s} with locally defined mutually
497 invisible macros \VAR{foo} which are enclosed in implicit \SO{block}s
498 of the same name.
501 \IT{(\SO*{SYMBOL-MACROLET} (\OPn{(\VAR{foo}
502 \VAR{expansion-form})}) \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
503 \PROGN{\VAR{form}})}
505 Evaluate \retval{\VAR{form}s} with locally defined symbol macros
506 \VAR{foo}.
509 \IT{(\MC*{DEFSETF} \NEV{\VAR{function}} \xorGOO{%
510 \NEV{\VAR{updater}} \text{ } \Op{\NEV{\VAR{doc}}}\\
511 (\OPn{\VAR{setf-$\lambda$}}) \text{ } (\OPn{\VAR{s-var}}) \text{ }
512 \OPn{(\kwd{declare } \OPn{\NEV{\VAR{decl}}})}\text{ }
513 \Op{\NEV{\VAR{doc}}} \text{ } \PROGN{\VAR{form}}}{\}})
514 \penalty-5
515 where defsetf lambda list (\OPn{\VAR{setf-$\lambda$}}) has the form
516 \penalty-5
517 (\OPn{\VAR{var}}
518 \OP{\kwd{\&optional} \xorGOO{%
519 \VAR{var}\\
520 (\VAR{var } \OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
521 \penalty-5
522 \Op{\kwd{\&rest} \VAR{var}}
523 \penalty-5
524 \OP{\kwd{\&key} \xorGOO{%
525 \VAR{var}\\
526 (\xorGOO{%
527 \VAR{var}\\
528 (\kwd{:}\VAR{key } \VAR{var})}{\}}
529 \text{ }\OP{\VAR{init}\DF{\NIL}\text{ }\Op{\VAR{supplied-p}}})}{\}^{\!\!*}}
530 \penalty-5
531 \Op{\kwd{\&allow-other-keys}}}
532 \penalty-5
533 \OP{\kwd{\&environment} \VAR{var}}%
537 Specify how to \kwd{setf} a place accessed by
538 \retval{\VAR{function}}.
539 \EM{Short form:} (\kwd{setf} (\VAR{function} \OPn{\VAR{arg}}) \VAR{value-form}) is
540 replaced by (\VAR{updater} \OPn{\VAR{arg}} \VAR{value-form}); the
541 latter must return \VAR{value-form}.
542 \EM{Long form:} on invocation of (\kwd{setf} (\VAR{function}
543 \OPn{\VAR{arg}}) \VAR{value-form}), \VAR{form}s must expand
544 into code that sets the place accessed where \VAR{setf-$\lambda$}
545 and \OPn{\VAR{s-var}} describe the arguments of \VAR{function} and
546 the value(s) to be stored, respectively; and that returns
547 the value(s) of \OPn{\VAR{s-var}}. \VAR{form}s are enclosed in an
548 implicit \SO{block} named \VAR{function}.
551 \IT{(\MC*{DEFINE-SETF-EXPANDER} \VAR{function}
552 (\OPn{\VAR{macro-$\lambda$}})
553 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \Op{\NEV{\VAR{doc}}}
554 \PROGN{\VAR{form}})}
556 Specify how to \kwd{setf} a place accessed by
557 \retval{\VAR{function}}. On invocation of (\kwd{setf} (\VAR{function}
558 \OPn{\VAR{arg}}) \VAR{value-form}), \OPn{\VAR{form}} must expand
559 into code returning \VAR{arg-vars}, \VAR{args}, \VAR{newval-vars},
560 \VAR{set-form}, and \VAR{get-form} as described with
561 \FU{GET-SETF-EXPANSION} where the elements of macro
562 lambda list \OPn{\VAR{macro-$\lambda$}} are bound to corresponding
563 \VAR{arg}s. \VAR{form}s are enclosed in an implicit \SO{block}
564 named \VAR{function}.
567 \IT{(\FU*{GET-SETF-EXPANSION} \VAR{place} \Op{\VAR{environment}\DF{\NIL}})}
569 Return lists of temporary variables \retval{\VAR{arg-vars}} and of
570 corresponding \retvalii{\VAR{args}} as given with \VAR{place},
571 list \retvaliii{\VAR{\VAR{newval-vars}}} with temporary variables
572 corresponding to the new values, and \retvaln{4}{\VAR{set-form}}
573 and \retvaln{5}{\VAR{get-form}} specifying in terms of \VAR{arg-vars}
574 and \VAR{newval-vars} how to \kwd{setf} and how to read
575 \VAR{place}.
578 \IT{(\MC*{DEFINE-MODIFY-MACRO} \VAR{foo}
579 (\OP{\kwd{\&optional} \xorGOO{%
580 \VAR{var}\\
581 (\VAR{var } \OP{\VAR{init}\DF{\NIL}\text{ }
582 \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
583 \Op{\kwd{\&rest} \VAR{var}})
584 \VAR{function} \Op{\NEV{\VAR{doc}}})}
586 Define macro \retval{\VAR{foo}} able to modify a place. On
587 invocation of (\VAR{foo} \VAR{place} \OPn{\VAR{arg}}), the value of
588 \VAR{function} applied to \VAR{place} and \VAR{arg}s will be stored into
589 \VAR{place} and returned.
592 \IT{\CNS*{LAMBDA-LIST-KEYWORDS}}
593 {List of macro lambda list keywords. These are at least:
595 \begin{LIST}{.5cm}
597 \IT{\kwd*{\&whole} \VAR{var}}
598 {Bind \VAR{var} to the entire macro call form.}
600 \IT{\kwd*{\&optional} \OPn{\VAR{var}}}
601 {Bind \VAR{var}s to corresponding arguments if any.}
603 \IT{\Goo{%
604 \kwd*{\&rest}\XOR
605 \kwd*{\&body}} \VAR{var}}
606 {Bind \VAR{var} to a list of remaining arguments.}
608 \IT{\kwd*{\&key} \OPn{\VAR{var}}}
609 {Bind \VAR{var}s to corresponding keyword arguments.}
611 \IT{\kwd*{\&allow-other-keys}}
613 Suppress keyword argument checking. Callers can do so using
614 \kwd*{:allow-other-keys}~\T.
617 \IT{\kwd*{\&environment} \VAR{var}}
618 {Bind \VAR{var} to the lexical compilation environment.}
620 \IT{\kwd*{\&aux} \OPn{\VAR{var}}}
621 {Bind \VAR{var}s as in \SO{let\A}.}
623 \end{LIST}
624 \end{LIST}
627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
628 \subsection{Control Flow}
629 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
630 \begin{LIST}{1cm}
632 \IT{(\SO*{IF} \VAR{test} \VAR{then} \Op{\VAR{else}\DF{\NIL}})}
634 Return values of \retval{\VAR{then}} if \VAR{test} returns \T;
635 return values of \retval{\VAR{else}} otherwise.
638 \IT{(\MC*{COND} \OPn{(\VAR{test} \PROGN{\VAR{then}}\DF{\VAR{test}})})}
640 Return the \retval{values} of the first \OPn{\VAR{then}} whose
641 \VAR{test} returns \T; return \retval{\NIL} if all \VAR{test}s
642 return \NIL.
645 \IT{(\xorGOO{\MC*{WHEN}\\
646 \MC*{UNLESS}}{\}} \VAR{test}
647 \PROGN{\VAR{foo}})}
649 Evaluate \VAR{foo}s and return \retval{their values} if \VAR{test}
650 returns \T\ or \NIL, respectively. Return \retval{\NIL} otherwise.
653 \IT{(\MC*{CASE} \VAR{test} \OPn{(\xorGOO{(\OPn{\NEV{\VAR{key}}})\\
654 \NEV{\VAR{key}}}{\}} \PROGN{\VAR{foo}})}
655 \OP{(\xorGOO{\kwd*{OTHERWISE}\\
656 \T}{\}} \PROGN{\VAR{bar}})\DF{\NIL}})}
658 Return the \retval{values of the first \OPn{\VAR{foo}}} one of
659 whose \VAR{key}s is \kwd{eql} \VAR{test}. Return \retval{values of
660 \VAR{bar}s} if there is no matching \VAR{key}.
661 % Keep \OPn{\VAR{foo}} instead of the otherwise preferable
662 % \VAR{foo}s because we're talking about one set of foos out
663 % of several.
666 \IT{(\xorGOO{\MC*{ECASE}\\
667 \MC*{CCASE}}{\}} \VAR{test}
668 \OPn{(\xorGOO{(\OPn{\NEV{\VAR{key}}})\\
669 \NEV{\VAR{key}}}{\}} \PROGN{\VAR{foo}})})}
671 Return the \retval{values of the first \OPn{\VAR{foo}}} one of
672 whose \VAR{key}s is \kwd{eql} \VAR{test}. Signal
673 non-correctable/correctable \kwd{type-error} if there is no
674 matching \VAR{key}.
675 % Keep \OPn{\VAR{foo}} instead of the otherwise preferable
676 % \VAR{foo}s because we're talking about one set of foos out
677 % of several.
680 \IT{(\MC*{AND} \OPn{\VAR{form}}\DF{\T})}
682 Evaluate \VAR{form}s from left to right. Immediately return
683 \retval{\NIL} if one \VAR{form}'s value is \NIL. Return
684 \retval{values of last \VAR{form}} otherwise.
687 \IT{(\MC*{OR} \OPn{\VAR{form}}\DF{\NIL})}
689 Evaluate \VAR{form}s from left to
690 right. Immediately return \retval{primary value} of first
691 non-\NIL-evaluating form, or \retval{all values} if last \VAR{form}
692 is reached. Return \retval{\NIL} if no \VAR{form} returns \T.
695 \IT{(\SO*{PROGN} \OPn{\VAR{form}}\DF{\NIL})}
696 {\label{:progn}
697 Evaluate \VAR{form}s sequentially. Return
698 \retval{values of last \VAR{form}}.
701 \IT{\arrGOO{%
702 (\SO*{MULTIPLE-VALUE-PROG1} \VAR{ form-r} \OPn{\VAR{ form}})\\
703 (\MC*{PROG1} \VAR{ form-r} \OPn{\VAR{ form}})\\
704 (\MC*{PROG2} \VAR{ form-a} \VAR{ form-r} \OPn{\VAR{ form}})}{.}}
706 Evaluate forms in order. Return \retval{values/primary value},
707 respectively, of \VAR{form-r}.
710 \IT{(\xorGOO{\MC*{PROG}\\
711 \MC*{PROG\A}}{\}}
712 (\orGOO{%
713 \VAR{name}\\
714 (\VAR{name } \Op{\VAR{value}\DF{\NIL}})}{\}^{\!\!*}})
715 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
716 \xorGOO{\NEV{\VAR{tag}}\\\VAR{form}}{\}^{\!\!*}})}
718 Evaluate \SO{TAGBODY}-like body with \VAR{name}s lexically bound (in
719 parallel or sequentially, respectively) to \VAR{value}s. Return
720 \retval{\NIL} or explicitly \retval{\MC{return}ed values}.
721 Implicitly, the whole form is a \SO{block} named \NIL.
724 \IT{(\SO*{UNWIND-PROTECT} \VAR{protected} \OPn{\VAR{cleanup}})}
726 Evaluate \VAR{protected} and then, no matter how control leaves
727 \VAR{protected}, \VAR{cleanup}s. Return \retval{values of
728 \VAR{protected}}.
731 \IT{(\SO*{BLOCK} \VAR{name} \PROGN{\VAR{form}})}
733 Evaluate \VAR{form}s in a lexical environment, and
734 return \retval{their values} unless interrupted by
735 \SO{RETURN-FROM}.
738 \IT{\arrGOO{(\SO*{RETURN-FROM } \VAR{foo } \Op{\VAR{result}\DF{\NIL}})\\
739 (\MC*{RETURN } \Op{\VAR{result}\DF{\NIL}})}{.}}
741 Have nearest enclosing \SO{block} named \VAR{foo}/named \NIL,
742 respectively, return with values of \VAR{result}.
745 \IT{(\SO*{TAGBODY} \Goos{\NEV{\VAR{tag}}\XOR\VAR{form}})}
747 Evaluate \VAR{form}s in a lexical environment. \VAR{tag}s (symbols
748 or integers) have lexical scope and dynamic extent, and are
749 targets for \SO{GO}. Return \retval{\NIL}.
752 \IT{(\SO*{GO} \NEV{\VAR{tag}})}
754 Within the innermost possible enclosing \SO{tagbody}, jump to a
755 tag \FU{eql} \VAR{tag}.
758 \IT{(\SO*{CATCH} \VAR{tag} \PROGN{\VAR{form}})}
760 Evaluate \VAR{form}s and return \retval{their values} unless
761 interrupted by \SO{THROW}.
764 \IT{(\SO*{THROW} \VAR{tag} \VAR{form})}
766 Have the nearest dynamically
767 enclosing \SO{CATCH} with a tag \FU{eq} \VAR{tag} return with the
768 values of \VAR{form}.
771 \IT{(\FU*{SLEEP} \VAR{n})}
773 Wait \VAR{n} seconds; return \retval{\NIL}.
776 \end{LIST}
779 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
780 \subsection{Iteration}
781 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
783 \begin{LIST}{1cm}
785 \IT{(\xorGOO{\MC*{DO}\\
786 \MC*{DO\A}}{\}}
787 (\xorGOO{%
788 \VAR{var}\\
789 (\VAR{var } \OP{ \VAR{start } \Op{\VAR{step}}})}{\}^{\!\!*}})
790 (\VAR{stop} \PROGN{\VAR{result}})
791 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
792 \xorGOO{\NEV{\VAR{tag}}\\\VAR{form}}{\}^{\!\!*}})}
794 Evaluate \SO{TAGBODY}-like body with \VAR{var}s successively bound
795 according to the values of the corresponding \VAR{start} and
796 \VAR{step} forms. \VAR{var}s are bound in parallel/sequentially,
797 respectively. Stop iteration when \VAR{stop} is \T. Return
798 \retval{values of \OPn{\VAR{result}}}. Implicitly, the whole form
799 is a \SO{block} named \NIL.
802 \IT{(\MC*{DOTIMES} (\VAR{var} \VAR{i} \Op{\VAR{result}\DF{\NIL}})
803 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
804 \Goos{\NEV{\VAR{tag}}\XOR\VAR{form}})}
806 Evaluate \SO{TAGBODY}-like body with \VAR{var} successively bound
807 to integers from 0 to $i - 1$. Upon evaluation of
808 \retval{\VAR{result}}, \VAR{var} is \VAR{i}. Implicitly, the whole
809 form is a \SO{block} named \NIL.
812 \IT{(\MC*{DOLIST }(\VAR{var} \VAR{list} \Op{\VAR{result}\DF{\NIL}})
813 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
814 \Goos{\NEV{\VAR{tag}}\XOR\VAR{form}})}
816 Evaluate \SO{TAGBODY}-like body with \VAR{var} successively bound
817 to the elements of \VAR{list}. Upon evaluation of
818 \retval{\VAR{result}}, \VAR{var} is \NIL. Implicitly, the whole form
819 is a \SO{block} named \NIL.
823 \end{LIST}
825 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
826 \subsection{Loop Facility}
827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 \label{section:Loop Facility}
830 \begin{LIST}{1cm}
832 \IT{(\MC*{LOOP} \OPn{\VAR{form}})}
834 \EM{Simple Loop. } If \VAR{form}s do not contain any atomic Loop
835 Facility keywords, evaluate them forever in an implicit \SO{block}
836 named \NIL.
839 \IT{(\MC*{LOOP} \OPn{\VAR{clause}})}
841 \EM{Loop Facility. } For Loop Facility keywords
842 see below and Figure \ref{loop-overview}.
845 \begin{LIST}{.5cm}
847 \IT{\LKWD*{named} \VAR{n}\DF{\NIL}}
849 Give \MC{loop}'s implicit \SO{block} a name.
852 \IT{\Goop{\LKWD*{with}
853 \xorGOO{%
854 \VAR{var-s}\\
855 (\OPn{\VAR{var-s}})}{\}}
856 \Op{\VAR{d-type}}
857 \Op{\LKWD*{=} \VAR{foo}}}
858 \Goos{\LKWD*{and}
859 \xorGOO{%
860 \VAR{var-p}\\
861 (\OPn{\VAR{var-p}})}{\}}
862 \Op{\VAR{d-type}}
863 \Op{\LKWD*{=} \VAR{bar}}}
864 \penalty-10
865 where destructuring type specifier \VAR{d-type} has the form
866 \penalty-5
867 \GOO{\kwd{fixnum}\XOR
868 \kwd{float}\XOR
869 \T\XOR
870 \NIL\XOR
871 \GOo{%
872 \LKWD*{of-type}
873 \xorGOO{\VAR{type}\\
874 (\OPn{\VAR{type}})}{\}}}}
877 Initialize (possibly trees of) local variables \VAR{var-s}
878 sequentially and \VAR{var-p} in parallel.
881 \begin{figure}%
882 \begin{center}%
883 \begin{sideways}%
885 \arraycolsep0pt
887 \text{\kwd{loop}}\text{ }
888 \Op{
889 \text{\LKWD{named} \VAR{n}\DF{\NIL}}
891 \left\{
892 \begin{array}{l}
893 \text{\LKWD{with}
894 \xorGOO{%
895 \VAR{var}\\
896 (\OPn{\VAR{var}})}{\}}
897 \Op{\VAR{d-type}}
898 \Op{\LKWD{=} \VAR{foo}}}
899 \text{ }
900 \{\text{\LKWD{and}
901 \xorGOO{%
902 \VAR{var}\\
903 (\OPn{\VAR{var}})}{\}}
904 \Op{\VAR{d-type}}
905 \Op{\LKWD{=} \VAR{bar}}}\}^{*} \\ \\[-2.4ex]
906 \left.\!
907 \begin{array}{l}
908 \text{\LKWD{for}} \\
909 \text{\LKWD{as}}
910 \end{array}\right\}
911 \boxed{
912 \text{\xorGOO{%
913 \VAR{var}\\
914 (\OPn{\VAR{var}})}{\}}}%
915 \Op{\VAR{d-type}}
916 \left\{
917 \begin{array}{l}
918 \left.\!
919 \begin{array}{l}
920 \OP{
921 \left\{
922 \begin{array}{l}
923 \text{\LKWD{upfrom}}\\
924 \text{\LKWD{from}}
925 \end{array}
926 \right\}
927 \text{\VAR{start}\DF{\LIT{0}}}
928 }\text{ }
929 \OP{
930 \left\{
931 \begin{array}{l}
932 \text{\LKWD{upto}}\\
933 \text{\LKWD{to}}\\
934 \text{\LKWD{below}}
935 \end{array}
936 \right\}
937 \text{\VAR{form}}
939 \text{\LKWD{from} \VAR{start}}
940 \left\{
941 \begin{array}{l}
942 \text{\LKWD{downto}}\\
943 \text{\LKWD{above}}
944 \end{array}
945 \right\}
946 \text{\VAR{form }}\\
947 \text{\LKWD{downfrom} \VAR{start}}\text{ }
948 \OP{
949 \left\{
950 \begin{array}{l}
951 \text{\LKWD{downto}}\\
952 \text{\LKWD{to}}\\
953 \text{\LKWD{above}}
954 \end{array}
955 \right\}
956 \text{\VAR{form}}
958 \end{array}
959 \right\}
960 \Op{
961 \text{\LKWD{by} \VAR{step}\DF{\LIT{1}}}
963 \left.\!
964 \begin{array}{l}
965 \text{\LKWD{in}} \\
966 \text{\LKWD{on}}
967 \end{array}
968 \right\}
969 \text{\VAR{list}}\text{ }
970 \Op{
971 \text{\LKWD{by} \VAR{function}\DF{\kwd{\#'cdr}}}
973 \text{\LKWD{=} \VAR{foo }}
974 \Op{
975 \text{\LKWD{then} \VAR{bar}\DF{\VAR{foo}}}
977 \text{\LKWD{across} \VAR{vector}}\\
978 \text{\LKWD{being}}
979 \left\{
980 \begin{array}{l}
981 \text{\LKWD{the}}\\
982 \text{\LKWD{each}}
983 \end{array}
984 \right\}%
985 \left\{
986 \begin{array}{{l}}
987 \left.\!
988 \begin{array}{l}
989 \text{\LKWD{hash-key\Op{s}}}
990 \left\{
991 \begin{array}{l}
992 \text{\LKWD{of}}\\
993 \text{\LKWD{in}}
994 \end{array}
995 \right\}
996 \text{\VAR{hash }}
997 \Op{
998 \text{\LKWD{using} (\LKWD{hash-value} \VAR{v})}%
1000 \text{\LKWD{hash-value\Op{s}}}
1001 \left\{
1002 \begin{array}{l}
1003 \text{\LKWD{of}}\\
1004 \text{\LKWD{in}}
1005 \end{array}
1006 \right\}
1007 \text{\VAR{hash }}
1008 \Op{
1009 \text{\LKWD{using} (\LKWD{hash-key} \VAR{k})}%
1011 \end{array}
1012 \right.\\
1013 \left.\!
1014 \begin{array}{l}
1015 \text{\LKWD{symbol\Op{s}}}\\
1016 \text{\LKWD{present-symbol\Op{s}}}\\
1017 \text{\LKWD{external-symbol\Op{s}}}
1018 \end{array}
1019 \right\}%
1020 \OP{
1021 \left\{
1022 \begin{array}{l}
1023 \text{\LKWD{of}}\\
1024 \text{\LKWD{in}}
1025 \end{array}
1026 \right\} \text{\VAR{package}\DF{\V{\A package\A}}}%
1028 \end{array}\!\!%
1029 \right.%
1030 \end{array}%
1031 \right\}_{{}^{{}^{\displaystyle{\mathbb{F}_0}}}}
1032 }%boxed
1033 \left\{
1034 \text{\LKWD{and} }\boxed{\mathbb{F}_i\!}
1035 \right\}^{\!*}\\
1036 \\[-2.4ex]
1037 \boxed{\;\mathbb{T}_1\,}
1039 \end{array}
1040 \right\}^{\displaystyle{\!\!*}}
1041 % Bottleneck
1042 \left\{
1043 \begin{array}{l}
1044 \boxed{
1045 \left.\!
1046 \begin{array}{l}
1047 \text{\LKWD{do\Op{ing}}}
1048 \text{ \VAR{form}}^{+}\\
1049 \left.\!
1050 \begin{array}{l}
1051 \text{\LKWD{if}}\\
1052 \text{\LKWD{when}}\\
1053 \text{\LKWD{unless}}
1054 \end{array}
1055 \right\}%
1056 \text{\VAR{test }}
1057 \boxed{\mathbb{C}_i\!}\{\text{\LKWD{and}}\,
1058 \boxed{\mathbb{C}_j\!}\}^{*}\Op{\text{\LKWD{else}}\,
1059 \boxed{\mathbb{C}_k\!}\{\text{\LKWD{and}}\,
1060 \boxed{\mathbb{C}_l\!}\}^{*}}
1061 \Op{\text{\LKWD{end}}}\!\!\!\!\!\!\!\\
1062 \text{\LKWD{return}}
1063 \left\{
1064 \begin{array}{l}
1065 \text{\VAR{form}}\\
1066 \text{\LKWD{it}}
1067 \end{array}
1068 \right.\\
1069 \left.\!
1070 \begin{array}{l}
1071 \text{\LKWD{collect\Op{ing}}}\\
1072 \text{\LKWD{append\Op{ing}}}\\
1073 \text{\LKWD{nconc\Op{ing}}}
1074 \end{array}
1075 \right\}
1076 \left\{
1077 \begin{array}{l}
1078 \text{\VAR{form}}\\
1079 \text{\LKWD{it}}
1080 \end{array}
1081 \right\} \Op{\text{\LKWD{into }\VAR{list}}}\\
1082 \left.\!
1083 \begin{array}{l}
1084 \text{\LKWD{count\Op{ing}}}\\
1085 \text{\LKWD{sum\Op{ming}}}\\
1086 \text{\LKWD{maximize}}\\
1087 \text{\LKWD{maximizing}}\\
1088 \text{\LKWD{minimize}}\\
1089 \text{\LKWD{minimizing}}
1090 \end{array}
1091 \right\}
1092 \left\{
1093 \begin{array}{l}
1094 \text{\VAR{form}}\\
1095 \text{\LKWD{it}}
1096 \end{array}
1097 \right\}
1098 \Op{\text{\LKWD{into }\VAR{num}}}\text{ }
1099 \Op{\text{\VAR{type}}}
1100 \end{array}
1101 \right._{{}^{{}^{\!\!\!\!\displaystyle{\mathbb{C}_0}}}}
1102 }%boxed
1104 \\[-2.4ex]
1105 \boxed{
1106 \left.\!
1107 \begin{array}{l}
1108 \left.\!
1109 \begin{array}{l}
1110 \text{\LKWD{initially}} \\
1111 \text{\LKWD{finally}}
1112 \end{array}
1113 \right\}
1114 \text{\VAR{form}}^{+}\\
1115 \text{\LKWD{repeat} \VAR{num}}\\
1116 \left.\!
1117 \begin{array}{l}
1118 \text{\LKWD{while}}\\
1119 \text{\LKWD{until}}\\
1120 \text{\LKWD{always}}\\
1121 \text{\LKWD{never}}\\
1122 \text{\LKWD{thereis}}
1123 \end{array}
1124 \right\}
1125 \text{\VAR{test}}
1126 \end{array}
1127 \right._{{}^{{}^{\displaystyle{\mathbb{T}_2}}}}
1128 }%boxed
1129 \end{array}
1130 \right\}^{\displaystyle{\!\!*}}
1132 \!)%
1133 \end{sideways}%
1134 \end{center}%
1135 \vspace{-3em}
1136 \raisebox{0em}[0em][0em]{\parbox[b]{4cm}{\caption{\protect\raggedright Loop Facility, Overview.\label{loop-overview}}}}
1137 \end{figure}
1139 \IT{\GOop{\Goo{\LKWD*{for}\XOR\LKWD*{as}}
1140 \xorGOO{%
1141 \VAR{var-s}\\
1142 (\OPn{\VAR{var-s}})}{\}}
1143 \Op{\VAR{d-type}}}
1144 \GOos{\LKWD*{and}
1145 \xorGOO{%
1146 \VAR{var-p}\\
1147 (\OPn{\VAR{var-p}})}{\}}
1148 \Op{\VAR{d-type}}}}
1150 Begin of iteration control clauses. Initialize and step (possibly
1151 trees of) local variables \VAR{var-s} sequentially and \VAR{var-p}
1152 in parallel. Destructuring type specifier \VAR{d-type} as with
1153 \LKWD{with}.
1156 \begin{LIST}{.5cm}
1158 \IT{\Goo{\LKWD*{upfrom}\XOR\LKWD*{from}\XOR\LKWD*{downfrom}}
1159 \VAR{start}}
1161 Start stepping with \VAR{start}
1164 \IT{\Goo{\LKWD*{upto}\XOR\LKWD*{downto}\XOR\LKWD*{to}\XOR\LKWD*{below}\XOR\LKWD*{above}}
1165 \VAR{form}}
1167 Specify \VAR{form} as the end value for stepping.
1170 \IT{\Goo{\LKWD*{in}\XOR\LKWD*{on}} \VAR{list}}
1172 Bind \VAR{var} to successive elements/tails, respectively, of
1173 \VAR{list}.
1176 \IT{\LKWD*{by} \Goo{\VAR{step}\DF{\LIT{1}}\XOR\VAR{function}\DF{\kwd{\#'cdr}}}}
1178 Specify the (positive) decrement or increment or the
1179 \VAR{function} of one argument returning the next part of the
1180 list.
1183 \IT{\LKWD*{=} \VAR{foo} \Op{\LKWD*{then}
1184 \VAR{bar}\DF{\VAR{foo}}}}
1186 Bind \VAR{var} initially to \VAR{foo} and later to
1187 \VAR{bar}.
1190 \IT{\LKWD*{across} \VAR{vector}}
1192 Bind \VAR{var} to successive elements of \VAR{vector}.
1195 \IT{\LKWD*{being} \Goo{\LKWD*{the}\XOR\LKWD*{each}}}
1197 Iterate over a hash table or a package.
1200 \begin{LIST}{.5cm}
1202 \IT{\Goo{\LKWD*{hash-key}\XOR\LKWD*{hash-keys}}
1203 \Goo{\LKWD*{of}\XOR\LKWD*{in}} \VAR{hash-table}
1204 \Op{\LKWD*{using} (\LKWD*{hash-value} \VAR{value})}}
1206 Bind \VAR{var} successively to the keys of \VAR{hash-table};
1207 bind \VAR{value} to corresponding values.
1210 \IT{\Goo{\LKWD*{hash-value}\XOR\LKWD*{hash-values}}
1211 \Goo{\LKWD*{of}\XOR\LKWD*{in}} \VAR{hash-table}
1212 \Op{\LKWD*{using} (\LKWD*{hash-key} \VAR{key})}}
1214 Bind \VAR{var} successively to the values of
1215 \VAR{hash-table}; bind \VAR{key} to corresponding keys.
1218 \IT{\Goo{\LKWD*{symbol}\XOR\LKWD*{symbols}\XOR\LKWD*{present-symbol}\XOR\LKWD*{present-symbols}\XOR\LKWD*{external-symbol}\XOR\LKWD*{external-symbols}}
1219 \Op{\Goo{\LKWD*{of}\XOR\LKWD*{in}}
1220 \VAR{package}\DF{\V{\A package\A}}}}
1222 Bind \VAR{var} successively to the accessible symbols, or
1223 the present symbols, or the external symbols respectively,
1224 of \VAR{package}.
1227 \end{LIST}
1228 \end{LIST}
1230 \IT{\Goo{\LKWD*{do}\XOR\LKWD*{doing}} \RP{\VAR{form}}}
1232 Evaluate \VAR{form}s in every iteration.
1235 \IT{\Goo{\LKWD*{if}\XOR\LKWD*{when}\XOR\LKWD*{unless}} \VAR{ test}
1236 \VAR{i-clause} \Goos{\LKWD*{and}
1237 \VAR{j-clause}} \Op{\LKWD*{else} \VAR{k-clause} \Goos{\LKWD*{and}
1238 \VAR{l-clause}}} \Op{\LKWD*{end}}}
1240 If \VAR{test} returns \T, \T, or \NIL, respectively, evaluate
1241 \VAR{i-clause} and \VAR{j-clause}s; otherwise, evaluate
1242 \VAR{k-clause} and \VAR{l-clause}s.
1245 \begin{LIST}{.5cm}
1246 \IT{\LKWD*{it}}
1248 Inside \VAR{i-clause} or \VAR{k-clause}:
1249 \retval{value of \VAR{test}}.
1251 \end{LIST}
1253 \IT{\LKWD*{return} \Goo{\VAR{form}\XOR\LKWD*{it}}}
1255 Return immediately, skipping any \LKWD{finally} parts, with
1256 values of \VAR{form} or \LKWD{it}.
1259 \IT{\Goo{\LKWD*{collect}\XOR\LKWD*{collecting}}
1260 \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into} \VAR{list}}}
1262 Collect values of \VAR{form} or \LKWD{it} into \VAR{list}. If no
1263 \VAR{list} is given, collect into an anonymous list which is
1264 returned after termination.
1267 \IT{\Goo{\LKWD*{append}\XOR\LKWD*{appending}\XOR\LKWD*{nconc}\XOR\LKWD*{nconcing}}
1268 \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into}
1269 \VAR{list}}}
1271 Concatenate values of \VAR{form} or \LKWD{it}, which should be
1272 lists, into \VAR{list} by the means of \FU{append} or \FU{nconc},
1273 respectively. If no \VAR{list} is given, collect into an
1274 anonymous list which is returned after termination.
1277 \IT{\Goo{\LKWD*{count}\XOR\LKWD*{counting}}
1278 \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into}
1279 \VAR{n}} \Op{\VAR{type}}}
1281 Count the number of times the value of \VAR{form} or of \LKWD{it} is \T.
1282 If no \VAR{n} is given, count into an anonymous variable
1283 which is returned after termination.
1286 \IT{\Goo{\LKWD*{sum}\XOR\LKWD*{summing}}
1287 \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into}
1288 \VAR{sum}} \Op{\VAR{type}}}
1290 Calculate the sum of the primary values of \VAR{form} or of \LKWD{it}.
1291 If no \VAR{sum} is given, sum into an anonymous variable
1292 which is returned after termination.
1295 \IT{\Goo{\LKWD*{maximize}\XOR\LKWD*{maximizing}\XOR
1296 \LKWD*{minimize}\XOR
1297 \LKWD*{minimizing}} \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into}
1298 \VAR{max-min}} \Op{\VAR{type}}}
1300 Determine the maximum or minimum, respectively, of the primary values of
1301 \VAR{form} or of \LKWD{it}.
1302 If no \VAR{max-min} is given, use an anonymous variable
1303 which is returned after termination.
1306 \IT{\Goo{\LKWD*{initially}\XOR\LKWD*{finally}} \RP{\VAR{form}}}
1308 Evaluate \VAR{form}s before begin, or after end, respectively,
1309 of iterations.
1312 \IT{\LKWD*{repeat} \VAR{num}}
1314 Terminate \MC{loop} after \VAR{num} iterations; \VAR{num} is
1315 evaluated once.
1318 \IT{\Goo{\LKWD*{while}\XOR\LKWD*{until}} \VAR{test}}
1320 Continue iteration until \VAR{test} returns \NIL\ or \T,
1321 respectively.
1324 \IT{\Goo{\LKWD*{always}\XOR\LKWD*{never}} \VAR{test}}
1326 Terminate \MC{loop} returning \NIL\ and skipping any
1327 \LKWD{finally} parts as soon as \VAR{test} is \NIL\ or \T,
1328 respectively. Otherwise continue \MC{loop} with its default
1329 return value set to \T.
1332 \IT{\LKWD*{thereis} \VAR{test}}
1334 Terminate \MC{loop} when \VAR{test} is \T\ and return value of
1335 \VAR{test}, skipping any \LKWD{finally} parts. Otherwise
1336 continue \MC{loop} with its default return value set to \NIL.
1339 \IT{(\MC*{loop-finish})}
1341 Terminate \MC{loop} immediately executing any \LKWD{finally}
1342 clauses and returning any accumulated results.
1344 \end{LIST}
1345 \end{LIST}
1350 % LocalWords: pt
1352 %%% Local Variables:
1353 %%% mode: latex
1354 %%% TeX-master: "clqr"
1355 %%% End: