Fix bugs reported by Fengjing Xiao
[clqr.git] / clqr-control-structure.tex
blob1ba144f2e57bbd0c0598f19397cf3b16b164d515
1 % Copyright (C) 2008, 2009, 2010, 2011, 2012, 2014, 2018
2 % Bert Burgemeister
3 %
4 % Permission is granted to copy, distribute and/or modify this
5 % document under the terms of the GNU Free Documentation License,
6 % Version 1.2; with no Invariant Sections, no Front-Cover Texts and
7 % no Back-Cover Texts. For details see file COPYING.
8 %
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 \section{Control Structure}
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 \subsection{Predicates}
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 \begin{LIST}{1cm}
19 \IT{(\FU*{EQ} \VAR{foo bar})}
21 \retval{\T} if \VAR{foo} and \VAR{bar} are identical.
24 \IT{(\FU*{EQL} \VAR{foo bar})}
26 \retval{\T} if \VAR{foo} and \VAR{bar}
27 are identical, or the same \kwd{character}, or \kwd{number}s of the
28 same type and value.
31 \IT{(\FU*{EQUAL} \VAR{foo bar})}
33 \retval{\T} if \VAR{foo} and \VAR{bar}
34 are \FU{EQL}, or are equivalent \kwd{pathname}s, or are \kwd{cons}es with
35 \FU{equal} cars and cdrs, or are \kwd{string}s or \kwd{bit-vector}s with
36 \FU{eql} elements below their fill pointers.
39 \IT{(\FU*{EQUALP} \VAR{foo bar})}
41 \retval{\T} if \VAR{foo} and \VAR{bar} are identical; or are the
42 same \kwd{character} ignoring case; or are \kwd{number}s of the same
43 value ignoring type; or are equivalent \kwd{pathname}s; or are
44 \kwd{cons}es or \kwd{array}s of the same shape with \FU{equalp}
45 elements; or are structures of the same type with
46 \FU{equalp} elements; or are \kwd{hash-table}s of the same size
47 with the same \kwd{:test} function, the same keys in terms of
48 \kwd{:test} function, and \FU{equalp} elements.
51 \IT{(\FU*{NOT} \VAR{foo})\qquad\qquad\qquad}
53 \retval{\T} if \VAR{foo} is \NIL; \retval{\NIL} otherwise.
56 \IT{(\FU*{BOUNDP} \VAR{symbol})\qquad\qquad}
58 \retval{\T} if \VAR{symbol} is a special variable.
61 \IT{(\FU*{CONSTANTP} \VAR{foo} \Op{\VAR{environment}\DF{\NIL}})}
63 \retval{\T} if \VAR{foo} is a constant form.
66 \IT{(\FU*{FUNCTIONP} \VAR{foo})\qquad\qquad}
68 \retval{\T} if \VAR{foo} is of type \kwd{function}.
71 \IT{(\FU*{FBOUNDP} \xorGOO{\VAR{foo}\\
72 (\kwd{setf } \VAR{foo})}{\}})}
74 \retval{\T} if \VAR{foo} is a global function or macro.
78 \end{LIST}
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 \subsection{Variables}
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
85 \begin{LIST}{1cm}
87 \IT{(\xorGOO{%
88 \MC*{DEFCONSTANT}\\
89 \MC*{DEFPARAMETER}}{\}} \NEV{\VAR{foo}} \VAR{form}
90 \Op{\NEV{\VAR{doc}}})}
92 Assign value of \VAR{form} to global constant/dynamic variable \retval{\VAR{foo}}.
95 \IT{(\MC*{DEFVAR} \NEV{\VAR{foo}} \OP{\VAR{form}
96 \Op{\NEV{\VAR{doc}}}})}
98 Unless bound already, assign value of \VAR{form} to dynamic variable
99 \retval{\VAR{foo}}.
102 \IT{(\xorGOO{\MC*{SETF}\\
103 \MC*{PSETF}}{\}} \Goos{\VAR{place}
104 \VAR{form}})}
106 Set \VAR{place}s to primary values of \VAR{form}s. Return \retval{values
107 of last \VAR{form}}/\retval{\NIL}; work sequentially/in parallel, respectively.
110 \IT{(\xorGOO{\SO*{SETQ}\\
111 \MC*{PSETQ}}{\}} \Goos{\VAR{symbol}
112 \VAR{form}})}
114 Set \VAR{symbol}s to primary values of \VAR{form}s. Return \retval{value
115 of last \VAR{form}}/\retval{\NIL}; work sequentially/in parallel, respectively.
118 \IT{(\FU*{SET} \DES{\VAR{symbol}} \VAR{foo})}
120 Set \VAR{symbol}'s value cell to \retval{\VAR{foo}}. Deprecated.
123 \IT{(\MC*{MULTIPLE-VALUE-SETQ} \VAR{vars} \VAR{form})}
125 Set elements of \VAR{vars} to the values of
126 \VAR{form}. Return \retval{\VAR{form}'s primary value}.
129 \IT{(\MC*{SHIFTF} \RP{\DES{\VAR{place}}} \VAR{foo})}
131 Store value of \VAR{foo} in rightmost \VAR{place} shifting values of
132 \VAR{place}s left, returning \retval{first \VAR{place}}.
135 \IT{(\MC*{ROTATEF} \OPn{\DES{\VAR{place}}})}
137 Rotate values of \VAR{place}s left, old first becoming new last
138 \VAR{place}'s value. Return \retval{\NIL}.
141 \IT{(\FU*{MAKUNBOUND} \DES{\VAR{foo}})}
143 Delete special variable \retval{\VAR{foo}} if any.
146 \label{:property_lists}
147 \IT{\arrGOO{(\FU*{GET} \VAR{ symbol} \VAR{ key }
148 \OP{\VAR{default}\DF{\NIL}})\\
149 (\FU*{GETF} \VAR{ place} \VAR{ key }
150 \OP{\VAR{default}\DF{\NIL}})}{.}}
152 \retval{First entry \VAR{key}} from property list stored in
153 \VAR{symbol}/in \VAR{place}, respectively, or \retval{\VAR{default}} if
154 there is no \VAR{key}. \kwd{setf}able.
157 \IT{(\FU*{GET-PROPERTIES} \VAR{property-list} \VAR{keys})}
159 Return \retval{key} and \retvalii{value} of first entry from \VAR{property-list}
160 matching a key from \VAR{keys}, and \retvaliii{tail of
161 \VAR{property-list}} starting with that key. Return \retval{\NIL},
162 \retvalii{\NIL}, and \retvaliii{\NIL} if there was no matching key
163 in \VAR{property-list}.
166 \IT{\arrGOO{(\FU*{REMPROP } \DES{\VAR{symbol}} \VAR{ key})\\
167 (\MC*{REMF } \DES{\VAR{place}} \VAR{ key})}{.}}
169 Remove first entry \VAR{key} from property list stored in
170 \VAR{symbol}/in \VAR{place}, respectively. Return \retval{\T} if \VAR{key}
171 was there, or \retval{\NIL} otherwise.
174 \IT{(\SO*{PROGV} \VAR{symbols} \VAR{values} \PROGN{\VAR{form}})}
176 Evaluate \VAR{form}s with locally established dynamic bindings of
177 \VAR{symbols} to \VAR{values} or \NIL. Return \retval{values of
178 \VAR{form}s}.
181 \IT{(\xorGOO{%
182 \SO*{LET}\\
183 \SO*{LET\A}}{\}} (%
184 \orGOO{\VAR{name}\\
185 (\VAR{name }\Op{\VAR{value}\DF{\NIL}})}{\}^{\!\!*}})
186 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
187 \PROGN{\VAR{form}})}
189 Evaluate \VAR{form}s with \VAR{name}s lexically bound (in parallel or
190 sequentially, respectively) to \VAR{value}s. Return
191 \retval{values of \VAR{form}s}.
194 \IT{(\MC*{MULTIPLE-VALUE-BIND} (\OPn{\NEV{\VAR{var}}}) \VAR{values-form}
195 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{body-form}})}
197 Evaluate \VAR{body-form}s with \VAR{var}s lexically bound to the
198 return values of \VAR{values-form}. Return \retval{values of
199 \VAR{body-form}s}.
202 \IT{(\MC*{DESTRUCTURING-BIND} \VAR{destruct-$\lambda$} \VAR{bar}
203 \OPn{(\kwd{declare}
204 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
206 Evaluate \VAR{form}s with variables from tree
207 \VAR{destruct-$\lambda$} bound to corresponding elements of tree
208 \VAR{bar}, and return \retval{their
209 values}. \VAR{destruct-$\lambda$} resembles \VAR{macro-$\lambda$}
210 (section \ref{section:Macros}), but without any \kwd{\&environment}
211 clause.
214 \end{LIST}
217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
218 \subsection{Functions}
219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 \label{section:Functions}
222 \begin{flushleft}
223 Below, ordinary lambda list (\OPn{\VAR{ord-$\lambda$}}) has the form\\
224 % \VAR{var} referenced from DEFSTRUCT
225 (\OPn{\VAR{var}}
226 \OP{\kwd{\&optional} \xorGOO{%
227 \VAR{var}\\
228 (\VAR{var } \OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
229 \penalty-5
230 \Op{\kwd{\&rest} \VAR{var}}
231 \penalty-5
232 \OP{\kwd{\&key} \xorGOO{%
233 \VAR{var}\\
234 (\xorGOO{%
235 \VAR{var}\\
236 (\kwd{:}\VAR{key } \VAR{var})}{\}}
237 \text{ }\OP{\VAR{init}\DF{\NIL}\text{ }\Op{\VAR{supplied-p}}})}{\}^{\!\!*}}
238 \penalty-5
239 \Op{\kwd{\&allow-other-keys}}}
240 \penalty-5
241 \OP{\kwd{\&aux} \xorGOO{%
242 \VAR{var}\\
243 (\VAR{var } \Op{\VAR{init}\DF{\NIL}})}{\}^{\!\!*}}}).
244 \end{flushleft}
245 \VAR{supplied-p} is \T\ if there is a corresponding
246 argument. \VAR{init} forms can refer to any \VAR{init} and
247 \VAR{supplied-p} to their left.
249 \begin{LIST}{1cm}
251 \IT{(\xorGOO{\MC*{DEFUN }\xorGOO{\VAR{foo }(\VAR{\OPn{ord-$\lambda$}})\\
252 (\kwd{setf} \VAR{ foo})\text{ }(\VAR{new-value } \VAR{\OPn{ord-$\lambda$}})}{.}\\
253 \MC*{LAMBDA }(\VAR{\OPn{ord-$\lambda$}})}{\}}
254 \orGOO{%
255 \OPn{(\kwd{declare } \OPn{\NEV{\VAR{decl}}})}\\
256 \NEV{\VAR{doc}}}{\}}
257 \PROGN{\VAR{form}})}
259 Define a function named \retval{\VAR{foo}} or \retval{(\kwd{setf}
260 \VAR{foo})}, or an anonymous \retval{function}, respectively, which applies
261 \VAR{form}s to \VAR{ord-$\lambda$}s. For \MC{defun}, \VAR{form}s are
262 enclosed in an implicit \SO{block} named \VAR{foo}.
265 \IT{(\xorGOO{\SO*{FLET}\\
266 \SO*{LABELS}}{\}}
267 (\OPn{(\xorGOO{\VAR{foo }(\OPn{\VAR{ord-$\lambda$}})\\
268 (\kwd{setf} \VAR{ foo})\text{ }(\VAR{new-value }\OPn{\VAR{ord-$\lambda$}})}{\}}
269 \orGOO{%
270 \OPn{(\kwd{declare } \OPn{\NEV{\VAR{local-decl}}})}\\
271 \NEV{\VAR{doc}}}{\}}
272 \PROGN{\VAR{local-form}})})
273 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
274 \PROGN{\VAR{form}})}
276 Evaluate \VAR{form}s with
277 locally defined functions \VAR{foo}. Globally defined functions of
278 the same name are shadowed. Each \VAR{foo} is also the name of an
279 implicit \SO{block} around its corresponding \OPn{\VAR{local-form}}.
280 Only for \SO{LABELS}, functions \VAR{foo} are visible inside
281 \VAR{local-forms}. Return \retval{values of \VAR{form}s}.
284 \IT{(\SO*{FUNCTION} \xorGOO{%
285 \VAR{foo}\\
286 (\MC{lambda } \OPn{\VAR{form}})}{\}})}
288 Return lexically innermost \retval{function} named \VAR{foo} or a
289 lexical closure of the \retval{\MC{lambda} expression}.
292 \IT{(\FU*{APPLY} \xorGOO{\VAR{function}\\
293 (\kwd{setf } \VAR{function})}{\}} \OPn{\VAR{arg}} \VAR{args})}
295 \retval{Values of \VAR{function}} called with
296 \VAR{arg}s and the list elements of \VAR{args}. \kwd{setf}able if
297 \VAR{function} is one of \FU{aref}, \FU{bit}, and \FU{sbit}.
300 \IT{(\FU*{FUNCALL} \VAR{function} \OPn{arg})}
302 \retval{Values of \VAR{function}} called with \VAR{arg}s.
305 \IT{(\SO*{MULTIPLE-VALUE-CALL} \VAR{function} \OPn{\VAR{form}})}
307 Call \VAR{function} with all the values of each \VAR{form} as its
308 arguments. Return \retval{values returned by \VAR{function}}.
311 \IT{(\FU*{VALUES-LIST} \VAR{list})}
313 Return \retval{elements of \VAR{list}}.
316 \IT{(\FU*{VALUES} \OPn{\VAR{foo}})}
318 Return as multiple values the \retval{primary values} of the
319 \VAR{foo}s. \kwd{setf}able.
322 \IT{(\FU*{MULTIPLE-VALUE-LIST} \VAR{form})}
324 \retval{List of the values of \VAR{form}}.
327 \IT{(\MC*{NTH-VALUE} \VAR{n} \VAR{form})}
329 Zero-indexed \retval{\VAR{n}th return value} of \VAR{form}.
332 \IT{(\FU*{COMPLEMENT} \VAR{function})}
334 Return \retval{new function} with same arguments and same side effects
335 as \VAR{function}, but with complementary truth value.
338 \IT{(\FU*{CONSTANTLY} \VAR{foo})}
340 \retval{Function} of any number of arguments returning \VAR{foo}.
343 \IT{(\FU*{IDENTITY} \VAR{foo})}
345 Return \retval{\VAR{foo}}.
348 \IT{(\FU*{FUNCTION-LAMBDA-EXPRESSION} \VAR{function})}
350 If available, return \retval{lambda expression} of \VAR{function},
351 \retvalii{\NIL} if \VAR{function} was defined in an environment
352 without bindings, and \retvaliii{name} of \VAR{function}.
355 \IT{(\FU*{FDEFINITION} \xorGOO{\VAR{foo}\\
356 (\kwd{setf } \VAR{foo})}{\}})}
358 \retval{Definition} of global function \VAR{foo}. \kwd{setf}able.
361 \IT{(\FU*{FMAKUNBOUND} \VAR{foo})}
363 Remove global function or macro definition \retval{\VAR{foo}}.
366 \IT{\arrGOO{\CNS*{CALL-ARGUMENTS-LIMIT}\\
367 \CNS*{LAMBDA-PARAMETERS-LIMIT}}{.}}
369 Upper bound of the number of function arguments or lambda list
370 parameters, respectively; $\geq50$.
373 \IT{\CNS*{MULTIPLE-VALUES-LIMIT}}
375 Upper bound of the number of values a multiple value can have;
376 $\geq20$.
379 \end{LIST}
382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383 \subsection{Macros}
384 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
385 \label{section:Macros}
387 \begin{flushleft}
388 Below, macro lambda list (\OPn{\VAR{macro-$\lambda$}}) has the form of
389 either
390 \penalty-5
391 (\Op{\kwd{\&whole} \VAR{var}}
392 \penalty-5
393 \Op{\VAR{E}}
394 \penalty-5
395 \xorGOO{%
396 \VAR{var}\\
397 (\OPn{\VAR{macro-$\lambda$}})}{\}^{\!\!*}}
398 \penalty-5
399 \Op{\VAR{E}}
400 \penalty-5
401 \Op{\kwd{\&optional}
402 \xorGOO{%
403 \VAR{var}\\
404 (\xorGOO{%
405 \VAR{var}\\
406 (\OPn{\VAR{macro-$\lambda$}})}{\}}\text{ }
407 \OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
408 \penalty-5
409 \Op{\VAR{E}}
410 \penalty-5
411 \Op{%
412 \xorGOO{%
413 \kwd{\&rest}\\
414 \kwd{\&body}}{\}}
415 \xorGOO{%
416 \VAR{rest-var}\\
417 (\OPn{\VAR{macro-$\lambda$}})}{\}}}
418 \penalty-5
419 \Op{\VAR{E}}
420 \penalty-5
421 \OP{\kwd{\&key}
422 \xorGOO{%
423 \VAR{var}\\
424 (\xorGOO{%
425 \VAR{var}\\
426 (\kwd{:}\VAR{key } \xorGOO{%
427 \VAR{var}\\
428 (\OPn{\VAR{macro-$\lambda$}})}{\}})}{\}}
429 \text{ }\OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}
430 \Op{\VAR{E}}
431 \Op{\kwd{\&allow-other-keys}}}
432 \penalty-5
433 \Op{\kwd{\&aux}
434 \xorGOO{%
435 \VAR{var}\\
436 (\VAR{var } \Op{\VAR{init}\DF{\NIL}})}{\}^{\!\!*}}}
437 \penalty-5
438 \Op{\VAR{E}})
442 \penalty-5
443 (\Op{\kwd{\&whole}
444 \VAR{var}}
445 \penalty-5
446 \Op{\VAR{E}}
447 \penalty-5
448 \xorGOO{%
449 \VAR{var}\\
450 (\OPn{\VAR{macro-$\lambda$}})}{\}^{\!\!*}}
451 \penalty-5
452 \Op{\VAR{E}}
453 \penalty-5
454 \Op{\kwd{\&optional}
455 \xorGOO{%
456 \VAR{var}\\
457 (\xorGOO{%
458 \VAR{var}\\
459 (\OPn{\VAR{macro-$\lambda$}})}{\}}\text{ }
460 \OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
461 \penalty-5
462 \Op{\VAR{E}}
463 \kwd{.}
464 \VAR{rest-var}).
465 \penalty-5
466 \end{flushleft}
467 One toplevel \Op{\VAR{E}} may be replaced by \kwd{\&environment}
468 \VAR{var}. \VAR{supplied-p} is \T\ if there is a corresponding
469 argument. \VAR{init} forms can refer to any \VAR{init} and
470 \VAR{supplied-p} to their left.
472 \begin{LIST}{1cm}
474 \IT{(\xorGOO{\MC*{DEFMACRO}\\
475 \MC*{DEFINE-COMPILER-MACRO}}{\}}
476 \xorGOO{\VAR{foo}\\
477 (\kwd{setf } \VAR{foo})}{\}}
478 (\OPn{\VAR{macro-$\lambda$}})
479 \orGOO{%
480 \OPn{(\kwd{declare } \OPn{\NEV{\VAR{decl}}})}\\
481 \NEV{\VAR{doc}}}{\}}
482 \PROGN{\VAR{form}})}
484 Define macro \retval{\VAR{foo}} which on evaluation as (\VAR{foo}
485 \VAR{tree}) applies expanded \VAR{form}s to arguments from
486 \VAR{tree}, which corresponds to \VAR{tree}-shaped
487 \VAR{macro-$\lambda$}s. \VAR{form}s are enclosed in an implicit
488 \SO{block} named \VAR{foo}.
491 \IT{(\MC*{DEFINE-SYMBOL-MACRO} \VAR{foo} \VAR{form})}
493 Define symbol macro \retval{\VAR{foo}} which on evaluation
494 evaluates expanded \VAR{form}.
497 \IT{(\SO*{MACROLET} (\OPn{(\VAR{foo} (\OPn{\VAR{macro-$\lambda$}})
498 \orGOO{%
499 \OPn{(\kwd{declare } \OPn{\NEV{\VAR{local-decl}}})}\\
500 \NEV{\VAR{doc}}}{\}} \PROGN{\VAR{macro-form}})})
501 \OPn{(\kwd{declare}
502 \OPn{\NEV{\VAR{decl}}})} \PROGN{\VAR{form}})}
504 Evaluate \retval{\VAR{form}s} with locally defined mutually
505 invisible macros \VAR{foo} which are enclosed in implicit
506 \SO{block}s of the same name.
509 \IT{(\SO*{SYMBOL-MACROLET} (\OPn{(\VAR{foo}
510 \VAR{expansion-form})}) \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
511 \PROGN{\VAR{form}})}
513 Evaluate \retval{\VAR{form}s} with locally defined symbol macros
514 \VAR{foo}.
517 \IT{(\MC*{DEFSETF} \NEV{\VAR{function}} \xorGOO{%
518 \NEV{\VAR{updater}} \text{ } \Op{\NEV{\VAR{doc}}}\\
519 (\OPn{\VAR{setf-$\lambda$}}) \text{ } (\OPn{\VAR{s-var}}) \text{ }
520 \orGOO{%
521 \OPn{(\kwd{declare } \OPn{\NEV{\VAR{decl}}})}\\
522 \NEV{\VAR{doc}}}{\}}
523 \text{ } \PROGN{\VAR{form}}}{\}})
524 \penalty-5
525 where defsetf lambda list (\OPn{\VAR{setf-$\lambda$}}) has the form
526 \penalty-5
527 (\OPn{\VAR{var}}
528 \OP{\kwd{\&optional} \xorGOO{%
529 \VAR{var}\\
530 (\VAR{var } \OP{\VAR{init}\DF{\NIL}\text{ } \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
531 \penalty-5
532 \Op{\kwd{\&rest} \VAR{var}}
533 \penalty-5
534 \OP{\kwd{\&key} \xorGOO{%
535 \VAR{var}\\
536 (\xorGOO{%
537 \VAR{var}\\
538 (\kwd{:}\VAR{key } \VAR{var})}{\}}
539 \text{ }\OP{\VAR{init}\DF{\NIL}\text{ }\Op{\VAR{supplied-p}}})}{\}^{\!\!*}}
540 \penalty-5
541 \Op{\kwd{\&allow-other-keys}}}
542 \penalty-5
543 \OP{\kwd{\&environment} \VAR{var}}%
547 Specify how to \kwd{setf} a place accessed by
548 \retval{\VAR{function}}.
549 \EM{Short form:} (\kwd{setf} (\VAR{function} \OPn{\VAR{arg}}) \VAR{value-form}) is
550 replaced by (\VAR{updater} \OPn{\VAR{arg}} \VAR{value-form}); the
551 latter must return \VAR{value-form}.
552 \EM{Long form:} on invocation of (\kwd{setf} (\VAR{function}
553 \OPn{\VAR{arg}}) \VAR{value-form}), \VAR{form}s must expand
554 into code that sets the place accessed where \VAR{setf-$\lambda$}
555 and \OPn{\VAR{s-var}} describe the arguments of \VAR{function} and
556 the value(s) to be stored, respectively; and that returns
557 the value(s) of \OPn{\VAR{s-var}}. \VAR{form}s are enclosed in an
558 implicit \SO{block} named \VAR{function}.
561 \IT{(\MC*{DEFINE-SETF-EXPANDER} \VAR{function}
562 (\OPn{\VAR{macro-$\lambda$}})
563 \orGOO{%
564 \OPn{(\kwd{declare } \OPn{\NEV{\VAR{decl}}})}\\
565 \NEV{\VAR{doc}}}{\}}
566 \PROGN{\VAR{form}})}
568 Specify how to \kwd{setf} a place accessed by
569 \retval{\VAR{function}}. On invocation of (\kwd{setf} (\VAR{function}
570 \OPn{\VAR{arg}}) \VAR{value-form}), \OPn{\VAR{form}} must expand
571 into code returning \VAR{arg-vars}, \VAR{args}, \VAR{newval-vars},
572 \VAR{set-form}, and \VAR{get-form} as described with
573 \FU{GET-SETF-EXPANSION} where the elements of macro
574 lambda list \OPn{\VAR{macro-$\lambda$}} are bound to corresponding
575 \VAR{arg}s. \VAR{form}s are enclosed in an implicit \SO{block}
576 named \VAR{function}.
579 \IT{(\FU*{GET-SETF-EXPANSION} \VAR{place} \Op{\VAR{environment}\DF{\NIL}})}
581 Return lists of temporary variables \retval{\VAR{arg-vars}} and of
582 corresponding \retvalii{\VAR{args}} as given with \VAR{place},
583 list \retvaliii{\VAR{\VAR{newval-vars}}} with temporary variables
584 corresponding to the new values, and \retvaln{4}{\VAR{set-form}}
585 and \retvaln{5}{\VAR{get-form}} specifying in terms of \VAR{arg-vars}
586 and \VAR{newval-vars} how to \kwd{setf} and how to read
587 \VAR{place}.
590 \IT{(\MC*{DEFINE-MODIFY-MACRO} \VAR{foo}
591 (\OP{\kwd{\&optional} \xorGOO{%
592 \VAR{var}\\
593 (\VAR{var } \OP{\VAR{init}\DF{\NIL}\text{ }
594 \Op{\VAR{supplied-p}}})}{\}^{\!\!*}}}
595 \Op{\kwd{\&rest} \VAR{var}})
596 \VAR{function} \Op{\NEV{\VAR{doc}}})}
598 Define macro \retval{\VAR{foo}} able to modify a place. On
599 invocation of (\VAR{foo} \VAR{place} \OPn{\VAR{arg}}), the value of
600 \VAR{function} applied to \VAR{place} and \VAR{arg}s will be
601 stored into \VAR{place} and returned.
604 \IT{\CNS*{LAMBDA-LIST-KEYWORDS}}
605 {List of macro lambda list keywords. These are at least:
607 \begin{LIST}{.5cm}
609 \IT{\kwd*{\&whole} \VAR{var}}
610 {Bind \VAR{var} to the entire macro call form.}
612 \IT{\kwd*{\&optional} \OPn{\VAR{var}}}
613 {Bind \VAR{var}s to corresponding arguments if any.}
615 \IT{\Goo{%
616 \kwd*{\&rest}\XOR
617 \kwd*{\&body}} \VAR{var}}
618 {Bind \VAR{var} to a list of remaining arguments.}
620 \IT{\kwd*{\&key} \OPn{\VAR{var}}}
621 {Bind \VAR{var}s to corresponding keyword arguments.}
623 \IT{\kwd*{\&allow-other-keys}}
625 Suppress keyword argument checking. Callers can do so using
626 \kwd*{:allow-other-keys}~\T.
629 \IT{\kwd*{\&environment} \VAR{var}}
630 {Bind \VAR{var} to the lexical compilation environment.}
632 \IT{\kwd*{\&aux} \OPn{\VAR{var}}}
633 {Bind \VAR{var}s as in \SO{let\A}.}
635 \end{LIST}
636 \end{LIST}
639 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
640 \subsection{Control Flow}
641 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
642 \begin{LIST}{1cm}
644 \IT{(\SO*{IF} \VAR{test} \VAR{then} \Op{\VAR{else}\DF{\NIL}})}
646 Return values of \retval{\VAR{then}} if \VAR{test} returns \T;
647 return values of \retval{\VAR{else}} otherwise.
650 \IT{(\MC*{COND} \OPn{(\VAR{test} \PROGN{\VAR{then}}\DF{\VAR{test}})})}
652 Return the \retval{values} of the first \OPn{\VAR{then}} whose
653 \VAR{test} returns \T; return \retval{\NIL} if all \VAR{test}s
654 return \NIL.
657 \IT{(\xorGOO{\MC*{WHEN}\\
658 \MC*{UNLESS}}{\}} \VAR{test}
659 \PROGN{\VAR{foo}})}
661 Evaluate \VAR{foo}s and return \retval{their values} if \VAR{test}
662 returns \T\ or \NIL, respectively. Return \retval{\NIL} otherwise.
665 \IT{(\MC*{CASE} \VAR{test} \OPn{(\xorGOO{(\OPn{\NEV{\VAR{key}}})\\
666 \NEV{\VAR{key}}}{\}} \PROGN{\VAR{foo}})}
667 \OP{(\xorGOO{\kwd*{OTHERWISE}\\
668 \T}{\}} \PROGN{\VAR{bar}})\DF{\NIL}})}
670 Return the \retval{values of the first \OPn{\VAR{foo}}} one of
671 whose \VAR{key}s is \kwd{eql} \VAR{test}. Return \retval{values of
672 \VAR{bar}s} if there is no matching \VAR{key}.
673 % Keep \OPn{\VAR{foo}} instead of the otherwise preferable
674 % \VAR{foo}s because we're talking about one set of foos out
675 % of several.
678 \IT{(\xorGOO{\MC*{ECASE}\\
679 \MC*{CCASE}}{\}} \VAR{test}
680 \OPn{(\xorGOO{(\OPn{\NEV{\VAR{key}}})\\
681 \NEV{\VAR{key}}}{\}} \PROGN{\VAR{foo}})})}
683 Return the \retval{values of the first \OPn{\VAR{foo}}} one of
684 whose \VAR{key}s is \kwd{eql} \VAR{test}. Signal
685 non-correctable/correctable \kwd{type-error} if there is no
686 matching \VAR{key}.
687 % Keep \OPn{\VAR{foo}} instead of the otherwise preferable
688 % \VAR{foo}s because we're talking about one set of foos out
689 % of several.
692 \IT{(\MC*{AND} \OPn{\VAR{form}}\DF{\T})}
694 Evaluate \VAR{form}s from left to right. Immediately return
695 \retval{\NIL} if one \VAR{form}'s value is \NIL. Return
696 \retval{values of last \VAR{form}} otherwise.
699 \IT{(\MC*{OR} \OPn{\VAR{form}}\DF{\NIL})}
701 Evaluate \VAR{form}s from left to
702 right. Immediately return \retval{primary value} of first
703 non-\NIL-evaluating form, or \retval{all values} if last \VAR{form}
704 is reached. Return \retval{\NIL} if no \VAR{form} returns \T.
707 \IT{(\SO*{PROGN} \OPn{\VAR{form}}\DF{\NIL})}
708 {\label{:progn}
709 Evaluate \VAR{form}s sequentially. Return
710 \retval{values of last \VAR{form}}.
713 \IT{\arrGOO{%
714 (\SO*{MULTIPLE-VALUE-PROG1} \VAR{ form-r} \OPn{\VAR{ form}})\\
715 (\MC*{PROG1} \VAR{ form-r} \OPn{\VAR{ form}})\\
716 (\MC*{PROG2} \VAR{ form-a} \VAR{ form-r} \OPn{\VAR{ form}})}{.}}
718 Evaluate forms in order. Return \retval{values/primary value},
719 respectively, of \VAR{form-r}.
722 \IT{(\xorGOO{\MC*{PROG}\\
723 \MC*{PROG\A}}{\}}
724 (\orGOO{%
725 \VAR{name}\\
726 (\VAR{name } \Op{\VAR{value}\DF{\NIL}})}{\}^{\!\!*}})
727 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
728 \xorGOO{\NEV{\VAR{tag}}\\\VAR{form}}{\}^{\!\!*}})}
730 Evaluate \SO{TAGBODY}-like body with \VAR{name}s lexically bound (in
731 parallel or sequentially, respectively) to \VAR{value}s. Return
732 \retval{\NIL} or explicitly \retval{\MC{return}ed values}.
733 Implicitly, the whole form is a \SO{block} named \NIL.
736 \IT{(\SO*{UNWIND-PROTECT} \VAR{protected} \OPn{\VAR{cleanup}})}
738 Evaluate \VAR{protected} and then, no matter how control leaves
739 \VAR{protected}, \VAR{cleanup}s. Return \retval{values of
740 \VAR{protected}}.
743 \IT{(\SO*{BLOCK} \VAR{name} \PROGN{\VAR{form}})}
745 Evaluate \VAR{form}s in a lexical environment, and
746 return \retval{their values} unless interrupted by
747 \SO{RETURN-FROM}.
750 \IT{\arrGOO{(\SO*{RETURN-FROM } \VAR{foo } \Op{\VAR{result}\DF{\NIL}})\\
751 (\MC*{RETURN } \Op{\VAR{result}\DF{\NIL}})}{.}}
753 Have nearest enclosing \SO{block} named \VAR{foo}/named \NIL,
754 respectively, return with values of \VAR{result}.
757 \IT{(\SO*{TAGBODY} \Goos{\NEV{\VAR{tag}}\XOR\VAR{form}})}
759 Evaluate \VAR{form}s in a lexical environment. \VAR{tag}s (symbols
760 or integers) have lexical scope and dynamic extent, and are
761 targets for \SO{GO}. Return \retval{\NIL}.
764 \IT{(\SO*{GO} \NEV{\VAR{tag}})}
766 Within the innermost possible enclosing \SO{tagbody}, jump to a
767 tag \FU{eql} \VAR{tag}.
770 \IT{(\SO*{CATCH} \VAR{tag} \PROGN{\VAR{form}})}
772 Evaluate \VAR{form}s and return \retval{their values} unless
773 interrupted by \SO{THROW}.
776 \IT{(\SO*{THROW} \VAR{tag} \VAR{form})}
778 Have the nearest dynamically
779 enclosing \SO{CATCH} with a tag \FU{eq} \VAR{tag} return with the
780 values of \VAR{form}.
783 \IT{(\FU*{SLEEP} \VAR{n})}
785 Wait \VAR{n} seconds; return \retval{\NIL}.
788 \end{LIST}
791 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
792 \subsection{Iteration}
793 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
795 \begin{LIST}{1cm}
797 \IT{(\xorGOO{\MC*{DO}\\
798 \MC*{DO\A}}{\}}
799 (\xorGOO{%
800 \VAR{var}\\
801 (\VAR{var } \OP{ \VAR{start } \Op{\VAR{step}}})}{\}^{\!\!*}})
802 (\VAR{stop} \PROGN{\VAR{result}})
803 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
804 \xorGOO{\NEV{\VAR{tag}}\\\VAR{form}}{\}^{\!\!*}})}
806 Evaluate \SO{TAGBODY}-like body with \VAR{var}s successively bound
807 according to the values of the corresponding \VAR{start} and
808 \VAR{step} forms. \VAR{var}s are bound in parallel/sequentially,
809 respectively. Stop iteration when \VAR{stop} is \T. Return
810 \retval{values of \OPn{\VAR{result}}}. Implicitly, the whole form
811 is a \SO{block} named \NIL.
814 \IT{(\MC*{DOTIMES} (\VAR{var} \VAR{i} \Op{\VAR{result}\DF{\NIL}})
815 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
816 \Goos{\NEV{\VAR{tag}}\XOR\VAR{form}})}
818 Evaluate \SO{TAGBODY}-like body with \VAR{var} successively bound
819 to integers from 0 to $i - 1$. Upon evaluation of
820 \retval{\VAR{result}}, \VAR{var} is \VAR{i}. Implicitly, the whole
821 form is a \SO{block} named \NIL.
824 \IT{(\MC*{DOLIST }(\VAR{var} \VAR{list} \Op{\VAR{result}\DF{\NIL}})
825 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
826 \Goos{\NEV{\VAR{tag}}\XOR\VAR{form}})}
828 Evaluate \SO{TAGBODY}-like body with \VAR{var} successively bound
829 to the elements of \VAR{list}. Upon evaluation of
830 \retval{\VAR{result}}, \VAR{var} is \NIL. Implicitly, the whole form
831 is a \SO{block} named \NIL.
835 \end{LIST}
837 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
838 \subsection{Loop Facility}
839 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
840 \label{section:Loop Facility}
842 \begin{LIST}{1cm}
844 \IT{(\MC*{LOOP} \OPn{\VAR{form}})}
846 \EM{Simple Loop. } If \VAR{form}s do not contain any atomic Loop
847 Facility keywords, evaluate them forever in an implicit \SO{block}
848 named \NIL.
851 \IT{(\MC*{LOOP} \OPn{\VAR{clause}})}
853 \EM{Loop Facility. } For Loop Facility keywords
854 see below and Figure \ref{loop-overview}.
857 \begin{LIST}{.5cm}
859 \IT{\LKWD*{named} \VAR{n}\DF{\NIL}}
861 Give \MC{loop}'s implicit \SO{block} a name.
864 \IT{\Goop{\LKWD*{with}
865 \xorGOO{%
866 \VAR{var-s}\\
867 (\OPn{\VAR{var-s}})}{\}}
868 \Op{\VAR{d-type}}
869 \Op{\LKWD*{=} \VAR{foo}}}
870 \Goos{\LKWD*{and}
871 \xorGOO{%
872 \VAR{var-p}\\
873 (\OPn{\VAR{var-p}})}{\}}
874 \Op{\VAR{d-type}}
875 \Op{\LKWD*{=} \VAR{bar}}}
876 \penalty-10
877 where destructuring type specifier \VAR{d-type} has the form
878 \penalty-5
879 \GOO{\kwd{fixnum}\XOR
880 \kwd{float}\XOR
881 \T\XOR
882 \NIL\XOR
883 \GOo{%
884 \LKWD*{of-type}
885 \xorGOO{\VAR{type}\\
886 (\OPn{\VAR{type}})}{\}}}}
889 Initialize (possibly trees of) local variables \VAR{var-s}
890 sequentially and \VAR{var-p} in parallel.
893 \begin{figure}%
894 \begin{center}%
895 \begin{sideways}%
897 \arraycolsep0pt
899 \text{\kwd{loop}}\text{ }
900 \Op{
901 \text{\LKWD{named} \VAR{n}\DF{\NIL}}
903 \left\{
904 \begin{array}{l}
905 \text{\LKWD{with}
906 \xorGOO{%
907 \VAR{var}\\
908 (\OPn{\VAR{var}})}{\}}
909 \Op{\VAR{d-type}}
910 \Op{\LKWD{=} \VAR{foo}}}
911 \text{ }
912 \{\text{\LKWD{and}
913 \xorGOO{%
914 \VAR{var}\\
915 (\OPn{\VAR{var}})}{\}}
916 \Op{\VAR{d-type}}
917 \Op{\LKWD{=} \VAR{bar}}}\}^{*} \\ \\[-2.4ex]
918 \left.\!
919 \begin{array}{l}
920 \text{\LKWD{for}} \\
921 \text{\LKWD{as}}
922 \end{array}\right\}
923 \boxed{
924 \text{\xorGOO{%
925 \VAR{var}\\
926 (\OPn{\VAR{var}})}{\}}}%
927 \Op{\VAR{d-type}}
928 \left\{
929 \begin{array}{l}
930 \left.\!
931 \begin{array}{l}
932 \OP{
933 \left\{
934 \begin{array}{l}
935 \text{\LKWD{upfrom}}\\
936 \text{\LKWD{from}}
937 \end{array}
938 \right\}
939 \text{\VAR{start}\DF{\LIT{0}}}
940 }\text{ }
941 \OP{
942 \left\{
943 \begin{array}{l}
944 \text{\LKWD{upto}}\\
945 \text{\LKWD{to}}\\
946 \text{\LKWD{below}}
947 \end{array}
948 \right\}
949 \text{\VAR{form}}
951 \text{\LKWD{from} \VAR{start}}
952 \left\{
953 \begin{array}{l}
954 \text{\LKWD{downto}}\\
955 \text{\LKWD{above}}
956 \end{array}
957 \right\}
958 \text{\VAR{form }}\\
959 \text{\LKWD{downfrom} \VAR{start}}\text{ }
960 \OP{
961 \left\{
962 \begin{array}{l}
963 \text{\LKWD{downto}}\\
964 \text{\LKWD{to}}\\
965 \text{\LKWD{above}}
966 \end{array}
967 \right\}
968 \text{\VAR{form}}
970 \end{array}
971 \right\}
972 \Op{
973 \text{\LKWD{by} \VAR{step}\DF{\LIT{1}}}
975 \left.\!
976 \begin{array}{l}
977 \text{\LKWD{in}} \\
978 \text{\LKWD{on}}
979 \end{array}
980 \right\}
981 \text{\VAR{list}}\text{ }
982 \Op{
983 \text{\LKWD{by} \VAR{function}\DF{\kwd{\#'cdr}}}
985 \text{\LKWD{=} \VAR{foo }}
986 \Op{
987 \text{\LKWD{then} \VAR{bar}\DF{\VAR{foo}}}
989 \text{\LKWD{across} \VAR{vector}}\\
990 \text{\LKWD{being}}
991 \left\{
992 \begin{array}{l}
993 \text{\LKWD{the}}\\
994 \text{\LKWD{each}}
995 \end{array}
996 \right\}%
997 \left\{
998 \begin{array}{{l}}
999 \left.\!
1000 \begin{array}{l}
1001 \text{\LKWD{hash-key\Op{s}}}
1002 \left\{
1003 \begin{array}{l}
1004 \text{\LKWD{of}}\\
1005 \text{\LKWD{in}}
1006 \end{array}
1007 \right\}
1008 \text{\VAR{hash }}
1009 \Op{
1010 \text{\LKWD{using} (\LKWD{hash-value} \VAR{v})}%
1012 \text{\LKWD{hash-value\Op{s}}}
1013 \left\{
1014 \begin{array}{l}
1015 \text{\LKWD{of}}\\
1016 \text{\LKWD{in}}
1017 \end{array}
1018 \right\}
1019 \text{\VAR{hash }}
1020 \Op{
1021 \text{\LKWD{using} (\LKWD{hash-key} \VAR{k})}%
1023 \end{array}
1024 \right.\\
1025 \left.\!
1026 \begin{array}{l}
1027 \text{\LKWD{symbol\Op{s}}}\\
1028 \text{\LKWD{present-symbol\Op{s}}}\\
1029 \text{\LKWD{external-symbol\Op{s}}}
1030 \end{array}
1031 \right\}%
1032 \OP{
1033 \left\{
1034 \begin{array}{l}
1035 \text{\LKWD{of}}\\
1036 \text{\LKWD{in}}
1037 \end{array}
1038 \right\} \text{\VAR{package}\DF{\V{\A package\A}}}%
1040 \end{array}\!\!%
1041 \right.%
1042 \end{array}%
1043 \right\}_{{}^{{}^{\displaystyle{\mathbb{F}_0}}}}
1044 }%boxed
1045 \left\{
1046 \text{\LKWD{and} }\boxed{\mathbb{F}_i\!}
1047 \right\}^{\!*}\\
1048 \\[-2.4ex]
1049 \boxed{\;\mathbb{T}_1\,}
1051 \end{array}
1052 \right\}^{\displaystyle{\!\!*}}
1053 % Bottleneck
1054 \left\{
1055 \begin{array}{l}
1056 \boxed{
1057 \left.\!
1058 \begin{array}{l}
1059 \text{\LKWD{do\Op{ing}}}
1060 \text{ \VAR{form}}^{+}\\
1061 \left.\!
1062 \begin{array}{l}
1063 \text{\LKWD{if}}\\
1064 \text{\LKWD{when}}\\
1065 \text{\LKWD{unless}}
1066 \end{array}
1067 \right\}%
1068 \text{\VAR{test }}
1069 \boxed{\mathbb{C}_i\!}\{\text{\LKWD{and}}\,
1070 \boxed{\mathbb{C}_j\!}\}^{*}\Op{\text{\LKWD{else}}\,
1071 \boxed{\mathbb{C}_k\!}\{\text{\LKWD{and}}\,
1072 \boxed{\mathbb{C}_l\!}\}^{*}}
1073 \Op{\text{\LKWD{end}}}\!\!\!\!\!\!\!\\
1074 \text{\LKWD{return}}
1075 \left\{
1076 \begin{array}{l}
1077 \text{\VAR{form}}\\
1078 \text{\LKWD{it}}
1079 \end{array}
1080 \right.\\
1081 \left.\!
1082 \begin{array}{l}
1083 \text{\LKWD{collect\Op{ing}}}\\
1084 \text{\LKWD{append\Op{ing}}}\\
1085 \text{\LKWD{nconc\Op{ing}}}
1086 \end{array}
1087 \right\}
1088 \left\{
1089 \begin{array}{l}
1090 \text{\VAR{form}}\\
1091 \text{\LKWD{it}}
1092 \end{array}
1093 \right\} \Op{\text{\LKWD{into }\VAR{list}}}\\
1094 \left.\!
1095 \begin{array}{l}
1096 \text{\LKWD{count\Op{ing}}}\\
1097 \text{\LKWD{sum\Op{ming}}}\\
1098 \text{\LKWD{maximize}}\\
1099 \text{\LKWD{maximizing}}\\
1100 \text{\LKWD{minimize}}\\
1101 \text{\LKWD{minimizing}}
1102 \end{array}
1103 \right\}
1104 \left\{
1105 \begin{array}{l}
1106 \text{\VAR{form}}\\
1107 \text{\LKWD{it}}
1108 \end{array}
1109 \right\}
1110 \Op{\text{\LKWD{into }\VAR{num}}}\text{ }
1111 \Op{\text{\VAR{type}}}
1112 \end{array}
1113 \right._{{}^{{}^{\!\!\!\!\displaystyle{\mathbb{C}_0}}}}
1114 }%boxed
1116 \\[-2.4ex]
1117 \boxed{
1118 \left.\!
1119 \begin{array}{l}
1120 \left.\!
1121 \begin{array}{l}
1122 \text{\LKWD{initially}} \\
1123 \text{\LKWD{finally}}
1124 \end{array}
1125 \right\}
1126 \text{\VAR{form}}^{+}\\
1127 \text{\LKWD{repeat} \VAR{num}}\\
1128 \left.\!
1129 \begin{array}{l}
1130 \text{\LKWD{while}}\\
1131 \text{\LKWD{until}}\\
1132 \text{\LKWD{always}}\\
1133 \text{\LKWD{never}}\\
1134 \text{\LKWD{thereis}}
1135 \end{array}
1136 \right\}
1137 \text{\VAR{test}}
1138 \end{array}
1139 \right._{{}^{{}^{\displaystyle{\mathbb{T}_2}}}}
1140 }%boxed
1141 \end{array}
1142 \right\}^{\displaystyle{\!\!*}}
1144 \!)%
1145 \end{sideways}%
1146 \end{center}%
1147 \vspace{-3em}
1148 \raisebox{0em}[0em][0em]{\parbox[b]{4cm}{\caption{\protect\raggedright Loop Facility, Overview.\label{loop-overview}}}}
1149 \end{figure}
1151 \IT{\GOop{\Goo{\LKWD*{for}\XOR\LKWD*{as}}
1152 \xorGOO{%
1153 \VAR{var-s}\\
1154 (\OPn{\VAR{var-s}})}{\}}
1155 \Op{\VAR{d-type}}}
1156 \GOos{\LKWD*{and}
1157 \xorGOO{%
1158 \VAR{var-p}\\
1159 (\OPn{\VAR{var-p}})}{\}}
1160 \Op{\VAR{d-type}}}}
1162 Begin of iteration control clauses. Initialize and step (possibly
1163 trees of) local variables \VAR{var-s} sequentially and \VAR{var-p}
1164 in parallel. Destructuring type specifier \VAR{d-type} as with
1165 \LKWD{with}.
1168 \begin{LIST}{.5cm}
1170 \IT{\Goo{\LKWD*{upfrom}\XOR\LKWD*{from}\XOR\LKWD*{downfrom}}
1171 \VAR{start}}
1173 Start stepping with \VAR{start}
1176 \IT{\Goo{\LKWD*{upto}\XOR\LKWD*{downto}\XOR\LKWD*{to}\XOR\LKWD*{below}\XOR\LKWD*{above}}
1177 \VAR{form}}
1179 Specify \VAR{form} as the end value for stepping.
1182 \IT{\Goo{\LKWD*{in}\XOR\LKWD*{on}} \VAR{list}}
1184 Bind \VAR{var} to successive elements/tails, respectively, of
1185 \VAR{list}.
1188 \IT{\LKWD*{by} \Goo{\VAR{step}\DF{\LIT{1}}\XOR\VAR{function}\DF{\kwd{\#'cdr}}}}
1190 Specify the (positive) decrement or increment or the
1191 \VAR{function} of one argument returning the next part of the
1192 list.
1195 \IT{\LKWD*{=} \VAR{foo} \Op{\LKWD*{then}
1196 \VAR{bar}\DF{\VAR{foo}}}}
1198 Bind \VAR{var} initially to \VAR{foo} and later to
1199 \VAR{bar}.
1202 \IT{\LKWD*{across} \VAR{vector}}
1204 Bind \VAR{var} to successive elements of \VAR{vector}.
1207 \IT{\LKWD*{being} \Goo{\LKWD*{the}\XOR\LKWD*{each}}}
1209 Iterate over a hash table or a package.
1212 \begin{LIST}{.5cm}
1214 \IT{\Goo{\LKWD*{hash-key}\XOR\LKWD*{hash-keys}}
1215 \Goo{\LKWD*{of}\XOR\LKWD*{in}} \VAR{hash-table}
1216 \Op{\LKWD*{using} (\LKWD*{hash-value} \VAR{value})}}
1218 Bind \VAR{var} successively to the keys of \VAR{hash-table};
1219 bind \VAR{value} to corresponding values.
1222 \IT{\Goo{\LKWD*{hash-value}\XOR\LKWD*{hash-values}}
1223 \Goo{\LKWD*{of}\XOR\LKWD*{in}} \VAR{hash-table}
1224 \Op{\LKWD*{using} (\LKWD*{hash-key} \VAR{key})}}
1226 Bind \VAR{var} successively to the values of
1227 \VAR{hash-table}; bind \VAR{key} to corresponding keys.
1230 \IT{\Goo{\LKWD*{symbol}\XOR\LKWD*{symbols}\XOR\LKWD*{present-symbol}\XOR\LKWD*{present-symbols}\XOR\LKWD*{external-symbol}\XOR\LKWD*{external-symbols}}
1231 \Op{\Goo{\LKWD*{of}\XOR\LKWD*{in}}
1232 \VAR{package}\DF{\V{\A package\A}}}}
1234 Bind \VAR{var} successively to the accessible symbols, or
1235 the present symbols, or the external symbols respectively,
1236 of \VAR{package}.
1239 \end{LIST}
1240 \end{LIST}
1242 \IT{\Goo{\LKWD*{do}\XOR\LKWD*{doing}} \RP{\VAR{form}}}
1244 Evaluate \VAR{form}s in every iteration.
1247 \IT{\Goo{\LKWD*{if}\XOR\LKWD*{when}\XOR\LKWD*{unless}} \VAR{ test}
1248 \VAR{i-clause} \Goos{\LKWD*{and}
1249 \VAR{j-clause}} \Op{\LKWD*{else} \VAR{k-clause} \Goos{\LKWD*{and}
1250 \VAR{l-clause}}} \Op{\LKWD*{end}}}
1252 If \VAR{test} returns \T, \T, or \NIL, respectively, evaluate
1253 \VAR{i-clause} and \VAR{j-clause}s; otherwise, evaluate
1254 \VAR{k-clause} and \VAR{l-clause}s.
1257 \begin{LIST}{.5cm}
1258 \IT{\LKWD*{it}}
1260 Inside \VAR{i-clause} or \VAR{k-clause}:
1261 \retval{value of \VAR{test}}.
1263 \end{LIST}
1265 \IT{\LKWD*{return} \Goo{\VAR{form}\XOR\LKWD*{it}}}
1267 Return immediately, skipping any \LKWD{finally} parts, with
1268 values of \VAR{form} or \LKWD{it}.
1271 \IT{\Goo{\LKWD*{collect}\XOR\LKWD*{collecting}}
1272 \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into} \VAR{list}}}
1274 Collect values of \VAR{form} or \LKWD{it} into \VAR{list}. If no
1275 \VAR{list} is given, collect into an anonymous list which is
1276 returned after termination.
1279 \IT{\Goo{\LKWD*{append}\XOR\LKWD*{appending}\XOR\LKWD*{nconc}\XOR\LKWD*{nconcing}}
1280 \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into}
1281 \VAR{list}}}
1283 Concatenate values of \VAR{form} or \LKWD{it}, which should be
1284 lists, into \VAR{list} by the means of \FU{append} or \FU{nconc},
1285 respectively. If no \VAR{list} is given, collect into an
1286 anonymous list which is returned after termination.
1289 \IT{\Goo{\LKWD*{count}\XOR\LKWD*{counting}}
1290 \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into}
1291 \VAR{n}} \Op{\VAR{type}}}
1293 Count the number of times the value of \VAR{form} or of \LKWD{it} is \T.
1294 If no \VAR{n} is given, count into an anonymous variable
1295 which is returned after termination.
1298 \IT{\Goo{\LKWD*{sum}\XOR\LKWD*{summing}}
1299 \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into}
1300 \VAR{sum}} \Op{\VAR{type}}}
1302 Calculate the sum of the primary values of \VAR{form} or of \LKWD{it}.
1303 If no \VAR{sum} is given, sum into an anonymous variable
1304 which is returned after termination.
1307 \IT{\Goo{\LKWD*{maximize}\XOR\LKWD*{maximizing}\XOR
1308 \LKWD*{minimize}\XOR
1309 \LKWD*{minimizing}} \Goo{\VAR{form}\XOR\LKWD*{it}} \Op{\LKWD*{into}
1310 \VAR{max-min}} \Op{\VAR{type}}}
1312 Determine the maximum or minimum, respectively, of the primary values of
1313 \VAR{form} or of \LKWD{it}.
1314 If no \VAR{max-min} is given, use an anonymous variable
1315 which is returned after termination.
1318 \IT{\Goo{\LKWD*{initially}\XOR\LKWD*{finally}} \RP{\VAR{form}}}
1320 Evaluate \VAR{form}s before begin, or after end, respectively,
1321 of iterations.
1324 \IT{\LKWD*{repeat} \VAR{num}}
1326 Terminate \MC{loop} after \VAR{num} iterations; \VAR{num} is
1327 evaluated once.
1330 \IT{\Goo{\LKWD*{while}\XOR\LKWD*{until}} \VAR{test}}
1332 Continue iteration until \VAR{test} returns \NIL\ or \T,
1333 respectively.
1336 \IT{\Goo{\LKWD*{always}\XOR\LKWD*{never}} \VAR{test}}
1338 Terminate \MC{loop} returning \NIL\ and skipping any
1339 \LKWD{finally} parts as soon as \VAR{test} is \NIL\ or \T,
1340 respectively. Otherwise continue \MC{loop} with its default
1341 return value set to \T.
1344 \IT{\LKWD*{thereis} \VAR{test}}
1346 Terminate \MC{loop} when \VAR{test} is \T\ and return value of
1347 \VAR{test}, skipping any \LKWD{finally} parts. Otherwise
1348 continue \MC{loop} with its default return value set to \NIL.
1351 \IT{(\MC*{loop-finish})}
1353 Terminate \MC{loop} immediately executing any \LKWD{finally}
1354 clauses and returning any accumulated results.
1356 \end{LIST}
1357 \end{LIST}
1362 % LocalWords: pt
1364 %%% Local Variables:
1365 %%% mode: latex
1366 %%% TeX-master: "clqr"
1367 %%% End: