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{Control Structure
}
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15 \subsection{Predicates
}
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 character, or the same number.
30 \IT{(
\FU*
{EQUAL
} \VAR{foo bar
})
}
32 \retval{\T} if
\VAR{foo
} and
\VAR{bar
}
33 are
\FU{EQL
}, or are conses with
\FU{equal
} cars and cdrs, or are
34 strings or bit-vectors with
\FU{eql
} elements, or are equivalent pathnames.
37 \IT{(
\FU*
{EQUALP
} \VAR{foo bar
})
}
39 \retval{\T} if
\VAR{foo
} and
\VAR{bar
}
40 are
\FU{EQUAL
}, or if they have corresponding components of the same
41 type which are
\FU{equalp
}.
44 \IT{(
\FU*
{NOT
} \VAR{bool
})
}
46 \retval{\NIL} if
\VAR{bool
} is
\T;
\retval{\T} if
\VAR{bool
} is
\NIL.
49 \IT{(
\FU*
{BOUNDP
} \VAR{symbol
})
}
51 \retval{\T} if
\VAR{symbol
} is a special variable.
54 \IT{(
\FU*
{CONSTANTP
} \VAR{foo
} \Op{\VAR{environment
}})
}
56 \retval{\T} if
\VAR{foo
} is a constant form.
59 \IT{(
\FU*
{FUNCTIONP
} \VAR{foo
})
}
61 \retval{\T} if
\VAR{foo
} is of type
\kwd{function
}.
64 \IT{(
\FU*
{FBOUNDP
} \VAR{foo
})
}
66 \retval{\T} if
\VAR{foo
} is a global function or macro.
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 \subsection{Variables
}
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 \IT{(
\MC*
{DEFVAR
} \NEV{\VAR{name
}} \OP{\VAR{form
}
80 \Op{\NEV{\VAR{doc
}}}})
}
82 Unless bound already, assign value of
\VAR{form
} to dynamic variable
86 \IT{(
\MC*
{DEFPARAMETER
} \NEV{\VAR{name
}} \VAR{form
}
87 \Op{\NEV{\VAR{doc
}}})
}
89 Assign value of
\VAR{form
} to dynamic variable
\retval{\VAR{name
}}.
92 \IT{(
\MC*
{DEFCONSTANT
} \NEV{\VAR{name
}} \VAR{form
}
93 \Op{\NEV{\VAR{doc
}}})
}
95 Assign value of
\VAR{form
} to global constant
\retval{\VAR{name
}}.
98 \IT{(
\xorGOO{\MC*
{SETF
}\\
99 \MC*
{PSETF
}}{\
}} \Goos{\VAR{place
}
102 Set
\VAR{place
}s to values of
\VAR{form
}s. Return
\retval{value
103 of last
\VAR{form
}}. Work sequentially/in parallel, respectively.
106 \IT{(
\xorGOO{\SO*
{SETQ
}\\
107 \MC*
{PSETQ
}}{\
}} \Goos{\VAR{symbol
}
110 Set
\VAR{symbol
}s to values of
\VAR{form
}s. Return
\retval{value
111 of last
\VAR{form
}}. Work sequentially/in parallel, respectively.
114 \IT{(
\FU*
{SET
} \DES{\VAR{symbol
}} \VAR{foo
})
}
116 Set
\VAR{symbol
}'s value cell to
\retval{\VAR{foo
}}.
119 \IT{(
\MC*
{MULTIPLE-VALUE-SETQ
} \VAR{vars
} \VAR{form
})
}
121 Set elements of
\VAR{vars
} to the values of
122 \VAR{form
}. Return
\retval{\VAR{form
}'s primary value
}.
125 \IT{(
\MC*
{SHIFTF
} \RP{\DES{\VAR{place
}}} \VAR{foo
})
}
127 Store value of
\VAR{foo
} in rightmost
\VAR{place
} shifting values of
128 \VAR{place
}s left, returning
\retval{first
\VAR{place
}}.
131 \IT{(
\MC*
{ROTATEF
} \OPn{\DES{\VAR{place
}}})
}
133 Rotate values of
\VAR{place
}s left, old first becoming new last
134 \VAR{place
}'s value. Return
\retval{\NIL}.
137 \IT{(
\FU*
{MAKUNBOUND
} \DES{\VAR{symbol
}})
}
139 Delete special variable
\retval{\VAR{symbol
}}.
142 \label{:property_lists
}
143 \IT{\arrGOO{(
\FU*
{GET
} \VAR{ symbol
} \VAR{ key
}
144 \OP{\VAR{default
}\DF{\NIL}})\\
145 (
\FU*
{GETF
} \VAR{ place
} \VAR{ key
}
146 \OP{\VAR{default
}\DF{\NIL}})
}{.
}}
148 \retval{First entry
\VAR{key
}} from property list stored in
149 \VAR{symbol
}/in
\VAR{place
}, respectively, or
\retval{\VAR{default
}} if
150 there was no
\VAR{key
}.
\kwd{setf
}able.
153 \IT{(
\FU*
{GET-PROPERTIES
} \VAR{property-list
} \VAR{keys
})
}
155 Return
\retval{key
} and
\retvalii{value
} of first entry from
\VAR{property-list
}
156 matching a key from
\VAR{keys
}, and
\retvaliii{tail of
157 \VAR{property-list
}} starting with that key. Return
\retval{\NIL},
158 \retvalii{\NIL}, and
\retvaliii{\NIL} if there was no matching key
159 in
\VAR{property-list
}.
162 \IT{\arrGOO{(
\FU*
{REMPROP
} \DES{\VAR{symbol
}} \VAR{ key
})\\
163 (
\MC*
{REMF
} \DES{\VAR{place
}} \VAR{ key
})
}{.
}}
165 Remove first entry
\VAR{key
} from property list stored in
166 \VAR{symbol
}/in
\VAR{place
}, respectively. Return
\retval{\T} if
\VAR{key
}
167 was there, or
\retval{\NIL} otherwise.
173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174 \subsection{Functions
}
175 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176 \label{section:Functions
}
179 Below, ordinary lambda list (
\OPn{\VAR{ord-$
\lambda$
}}) has the form\\
181 \OP{\kwd*
{\&optional
} \xorGOO{%
183 (
\VAR{var
} \OP{\VAR{init
} \Op{\VAR{supplied-p
}}})
}{\
}}}
185 \Op{\kwd*
{\&rest
} \VAR{var
}}
187 \OP{\kwd*
{\&key
} \xorGOO{%
191 (
\kwd{:
}\VAR{key
} \VAR{var
})
}{\
}}
192 \text{ }\OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
194 \Op{\kwd*
{\&allow-other-keys
}}}
196 \OP{\kwd*
{\&aux
} \xorGOO{%
198 (
\VAR{var
} \Op{\VAR{init
}})
}{\
}}}).\\
199 \VAR{supplied-p
} is
\T\ if there is a corresponding argument.
204 \IT{(
\xorGOO{\MC*
{DEFUN
} \VAR{ foo
}\\
\MC*
{LAMBDA
}}{\
}}
205 (
\VAR{\OPn{ord-$
\lambda$
}})
\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
209 Define function with
\retval{name
\VAR{foo
}} or an anonymous
210 function, respectively, which
211 applies
\VAR{form
}s to
\VAR{ord-$
\lambda$
}s.
214 \IT{(
\xorGOO{\SO*
{FLET
}\\
217 (
\OPn{\VAR{ord-$
\lambda$
}})
218 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{local-decl
}}})
}%
220 \OPn{\VAR{local-form
}})
})
\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
223 Evaluate
\VAR{form
}s with
224 locally defined functions
\VAR{foo
}. Only for
\SO{LABELS
},
225 \VAR{foo
}s are visible inside
\VAR{local-forms
}. Return
226 \retval{values of
\VAR{form
}s
}.
229 \IT{(
\SO*
{FUNCTION
} \VAR{foo
})
}
230 {Return
\retval{function named
\VAR{foo
}}.
233 \IT{(
\FU*
{APPLY
} \VAR{function
} \RP{\VAR{arg
}})
}
235 Return
\retval{value of
\VAR{function
}} called on
236 \VAR{arg
}s. Last
\VAR{arg
} must be a list.
239 \IT{(
\FU*
{FUNCALL
} \VAR{function
} \OPn{arg
})
}
241 Return
\retval{value of
\VAR{function
}} called with
\VAR{arg
}s.
244 \IT{(
\SO*
{MULTIPLE-VALUE-CALL
} \VAR{foo
} \OPn{\VAR{form
}})
}
246 \VAR{foo
} with all the values of
\VAR{form
}s as its arguments. Return
247 \retval{values returned by
\VAR{foo
}}.
250 \IT{(
\FU*
{VALUES-LIST
} \VAR{list
})
}
252 Return
\retval{elements of
\VAR{list
}}.
255 \IT{(
\FU*
{VALUES
} \OPn{\VAR{foo
}})
}
257 Return
\retval{\VAR{foo
}s
} as multiple values.
\kwd{setf
}able.
260 \IT{(
\FU*
{MULTIPLE-VALUE-LIST
} \VAR{form
})
}
262 Return in a
\retval{list
} values of
\VAR{form
}.
265 \IT{(
\FU*
{NTH-VALUE
} \VAR{n
} \VAR{form
})
}
267 Zero-indexed
\retval{\VAR{n
}th return value
} of
\VAR{form
}.
270 \IT{(
\FU*
{COMPLEMENT
} \VAR{function
})
}
272 Return
\retval{new function
} with same arguments and same side effects
273 as
\VAR{function
}, but with complementary truth value.
276 \IT{(
\FU*
{CONSTANTLY
} \VAR{foo
})
}
278 Return
\retval{function
} of any number of arguments returning
\VAR{foo
}.
281 \IT{(
\FU*
{IDENTITY
} \VAR{foo
})
}
283 Return
\retval{\VAR{foo
}}.
286 \IT{(
\FU*
{FUNCTION-LAMBDA-EXPRESSION
} \VAR{function
})
}
288 If available, return
\retval{lambda expression
} of
\VAR{function
},
289 \retvalii{\NIL} if
\VAR{function
} was defined in an environment
290 without bindings, and
\retvaliii{name
} of
\VAR{function
}.
293 \IT{(
\FU*
{FDEFINITION
} \VAR{foo
})
}
295 \retval{Definition
} of function
\VAR{foo
}.
\kwd{setf
}able.
298 \IT{(
\FU*
{FMAKUNBOUND
} \VAR{foo
})
}
300 Remove global function or macro definition
\retval{\VAR{foo
}}.
303 \IT{\arrGOO{\CNS*
{CALL-ARGUMENTS-LIMIT
}\\
304 \CNS*
{LAMBDA-PARAMETERS-LIMIT
}}{.
}}
306 Upper bound of the number of function arguments or lambda list
307 parameters, respectively; $
\geq50$.
310 \IT{\CNS*
{MULTIPLE-VALUES-LIMIT
}}
312 Upper bound of the number of values a function can return; $
\geq20$.
318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
320 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323 Below, macro lambda list (
\OPn{\VAR{macro-$
\lambda$
}}) has the form of
329 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}}
335 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}^
{\!\!*
}}
339 \Op{\kwd*
{\&optional
}
342 (
\VAR{var
} \OP{\VAR{init
} \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
352 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}}
361 (
\kwd{:
}\VAR{key
} \VAR{var
})
}{\
}}
362 \text{ }\OP{\VAR{init
} \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
364 \Op{\kwd*
{\&allow-other-keys
}}}
369 (
\VAR{var
} \Op{\VAR{init
}})
}{\
}^
{\!\!*
}}}
378 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}}
384 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}^
{\!\!*
}}
388 \Op{\kwd*
{\&optional
}
391 (
\VAR{var
} \OP{\VAR{init
} \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
397 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}).
399 One toplevel
\Op{\VAR{\&Ev
}} may be replaced by
\kwd*
{\&environment
}
400 \VAR{var
}.
\VAR{supplied-p
} is
\T\ if there is a corresponding
406 \IT{(
\xorGOO{\MC*
{DEFMACRO
}\\
407 \FU*
{DEFINE-COMPILER-MACRO
}}{\
}}
408 \VAR{foo
} (
\OPn{\VAR{macro-$
\lambda$
}})
409 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
} \Op{\NEV{\VAR{doc
}}}
412 Define macro
\retval{\VAR{foo
}} which on evaluation as (
\VAR{foo
}
413 \VAR{tree
}) applies expanded
\VAR{form
}s to arguments from
414 \VAR{tree
} which corresponds to
\VAR{tree
}-shaped
415 \VAR{macro-$
\lambda$
}s.
418 \IT{(
\MC*
{DEFINE-SYMBOL-MACRO
} \VAR{foo
} \VAR{form
})
}
420 Define symbol macro
\retval{\VAR{foo
}} which on evaluation evaluates
424 \IT{(
\SO*
{MACROLET
} (
\OPn{(
\VAR{name
} (
\OPn{\VAR{macro-$
\lambda$
}})
425 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{local-decl
}}})
}
426 \Op{\NEV{\VAR{doc
}}} \OPn{\VAR{macro-form
}})
})
\OPn{(
\kwd{declare
}
427 \OPn{\NEV{\VAR{decl
}}})
} \OPn{\VAR{form
}})
}
429 Evaluate
\retval{\VAR{form
}s
} with
\VAR{name
}s locally defined
430 as macros which are invisible to each other.
433 \IT{(
\SO*
{SYMBOL-MACROLET
} (
\OPn{(
\VAR{name
}
434 \VAR{expansion-form
})
})
\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
437 Evaluate
\retval{\VAR{form
}s
} with
\VAR{name
}s locally defined as
441 \IT{(
\MC*
{DEFSETF
} \NEV{\VAR{function
}} \xorGOO{%
442 \NEV{\VAR{update
}} \text{ } \Op{\NEV{\VAR{doc
}}}\\
443 (
\OPn{\VAR{setf-$
\lambda$
}})
\text{ } (
\OPn{\VAR{var
}})
\text{ }
444 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\text{ }
445 \Op{\NEV{\VAR{doc
}}} \text{ } \OPn{form
}}{\
}})
447 where setf lambda list (
\OPn{\VAR{setf-$
\lambda$
}}) has the form
450 \OP{\kwd*
{\&optional
} \xorGOO{%
452 (
\VAR{var
} \OP{\VAR{init
} \Op{\VAR{supplied-p
}}})
}{\
}}}
454 \Op{\kwd*
{\&rest
} \VAR{var
}}
456 \OP{\kwd*
{\&key
} \xorGOO{%
460 (
\kwd{:
}\VAR{key
} \VAR{var
})
}{\
}}
461 \text{ }\OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
463 \Op{\kwd*
{\&allow-other-keys
}}}
465 \OP{\kwd*
{\&environment
} \VAR{var
}}%
469 Specify how to
\kwd{setf
} a place accessed by
470 \retval{\VAR{function
}}.
%FIXME:AUGMENT
473 \IT{(
\MC*
{DEFINE-SETF-EXPANDER
} \VAR{function
} (
\OPn{\VAR{macro-$
\lambda$
}})
474 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
} \Op{\NEV{\VAR{doc
}}}
477 Specify how to
\kwd{setf
} a place accessed by
\retval{\VAR{function
}}.
480 \IT{(
\FU*
{GET-SETF-EXPANSION
} \VAR{place
} \Op{\VAR{environment
}})
}
482 Return five values describing how to
\kwd{setf
} place.
485 \IT{(
\MC*
{DEFINE-MODIFY-MACRO
} \VAR{foo
} (
\kwd{\&optional
}
486 \OPn{\VAR{var
}} \kwd{\&rest
} \OPn{\VAR{var
}})
\VAR{function
}
487 \Op{\NEV{\VAR{doc
}}})
}
489 Define macro
\retval{\VAR{foo
}} able to read and write a place.
492 \IT{\CNS*
{LAMBDA-LIST-KEYWORDS
}}
493 {List of macro lambda list keywords.
499 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
500 \subsection{Control Flow
}
501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
504 \IT{(
\SO*
{IF
} \VAR{test
} \VAR{then
} \Op{\VAR{else
}\DF{\NIL}})
}
506 \retval{\VAR{then
}} if
\VAR{test
} returns
\T; return value of
507 \retval{\VAR{else
}} otherwise.
510 \IT{(
\MC*
{COND
} \OPn{(
\VAR{test
} \OPn{\VAR{then
}}\DF{\VAR{test
}})
})
}
512 Return the
\retval{values
} of the first
513 \VAR{then
} whose
\VAR{test
} returns
\T; return
514 \retval{\NIL} if each
\VAR{test
} returns
\NIL.
517 \IT{(
\xorGOO{\MC*
{WHEN
}\\
518 \MC*
{UNLESS
}}{\
}} \VAR{test
}
519 \OPn{\VAR{foo
}}\DF{\NIL})
}
521 Evaluate
\VAR{foo
}s and return
\retval{values of last
\VAR{foo
}} if
522 \VAR{test
} returns
\T\ or
\NIL, respectively. Return
\retval{\NIL} otherwise.
525 \IT{(
\MC*
{CASE
} \VAR{test
} \OPn{(
\VAR{keys
} \OPn{\VAR{foo
}})
}
526 \Op{(
\Goo{\T\XOR\kwd*
{OTHERWISE
}} \OPn{\VAR{bar
}})
\DF{\NIL}})
}
528 Evaluate first
\VAR{foo
}s one of whose unevaluated
\VAR{keys
} is
529 \kwd{eql
} evaluated
\VAR{test
} and return
\retval{their values
}.
530 Return
\retval{values of
\VAR{bar
}s
} if no
\VAR{keys
} match.
533 \IT{(
\Goo{\MC*
{CCASE
}\XOR\MC*
{ECASE
}} \VAR{test
}
534 \OPn{(
\VAR{keys
} \OPn{\VAR{foo
}})
})
}
536 Evaluate first
\VAR{foo
}s one of whose unevaluated
\VAR{keys
} is
\kwd{eql
} evaluated
537 \VAR{test
} and return
\retval{their values
}. Signal correctable error/non-correctable
\kwd{type-error
},
538 respectively, if no
\VAR{keys
} match and return
\retval{\NIL} then.
541 \IT{(
\MC*
{AND
} \OPn{\VAR{form
}}\DF{\T})
}
543 Evaluate
\VAR{form
}s from left to
544 right. Immediately return
\retval{\NIL} if one
\VAR{form
}'s value is
\NIL. Return
545 \retval{values of last
\VAR{form
}} otherwise.
548 \IT{(
\MC*
{OR
} \OPn{\VAR{form
}}\DF{\NIL})
}
550 Evaluate
\VAR{form
}s from left to
551 right. Immediately return
\retval{primary value
} of first
552 non-
\NIL-evaluating form, or
\retval{all values
} if last
\VAR{form
}
553 is reached. Return
\retval{\NIL} if no
\VAR{form
} returns
\T.
556 \IT{(
\SO*
{PROGN
} \OPn{\VAR{form
}}\DF{\NIL})
}
557 {Evaluate
\VAR{form
}s sequentially. Return
558 \retval{values of last
\VAR{form
}}.
561 \IT{(
\xorGOO{\MC*
{PROG
}\\
565 (
\VAR{var
} \Op{ \VAR{value
}})
}{\
}^
{\!\!*
}})
566 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
567 \xorGOO{\NEV{\VAR{tag
}}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
569 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
}s locally bound (in parallel or sequentially, respectively) to
570 \VAR{value
}s. Return
\retval{\NIL} or explicitly
571 \retval{\MC{return
}ed value
}.
575 (
\SO*
{MULTIPLE-VALUE-PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
576 (
\MC*
{PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
577 (
\MC*
{PROG2
} \VAR{ form-a
} \VAR{ form-r
} \OPn{\VAR{ form
}})
}{.
}}
579 Evaluate forms in order. Return
\retval{values/
1st value
},
580 respectively, of
\VAR{form-r
}.
583 \IT{(
\SO*
{PROGV
} \VAR{symbols
} \VAR{values
} \OPn{\VAR{form
}})
}
585 Evaluate
\VAR{form
}s with
\VAR{symbols
} dynamically bound to
\VAR{values
} or
586 \NIL. Return
\retval{values returned by
\VAR{form
}s
}.
589 \IT{(
\MC*
{DESTRUCTURING-BIND
} \VAR{foo
} \VAR{bar
} \OPn{(
\kwd{declare
}
590 \OPn{\NEV{\VAR{decl
}}})
} \OPn{\VAR{form
}})
}
592 Evaluate
\VAR{form
}s, and return
\retval{values of last
\VAR{form
}},
593 with variables from tree
\VAR{foo
} bound to corresponding elements
597 \IT{(
\MC*
{MULTIPLE-VALUE-BIND
} (
\OPn{\VAR{var
}})
\VAR{values-form
}
598 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
} \OPn{\VAR{body-form
}})
}
600 \VAR{body-form
}s with
\VAR{var
}s bound to the return values of
601 \VAR{values-form
}. Return
\retval{values of
\VAR{body-form
}s
}.
604 \IT{(
\xorGOO{\SO*
{LET
}\\
607 (
\VAR{name
}\Op{\VAR{value
}})
}{\
}^
{\!\!*
}})
608 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
611 Evaluate
\VAR{form
}s with
\VAR{name
}s bound (in parallel or
612 sequentially, respectively) to
\VAR{value
}s or
\NIL. Return
613 \retval{values of
\VAR{form
}s
}.
616 \IT{(
\SO*
{LOCALLY
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
619 Evaluate
\VAR{form
}s with declarations
\VAR{decl
} in
620 effect. Return
\retval{values of
\VAR{form
}s
}.
623 \IT{(
\SO*
{RETURN-FROM
} \VAR{foo
} \Op{\VAR{result
}\DF{\NIL}})
}
625 Have nearest enclosing
\SO{block
} \VAR{foo
} return with
626 values of
\VAR{result
}.
629 \IT{(
\MC*
{RETURN
} \Op{\VAR{result
}\DF{\NIL}})
}
631 Have nearest enclosing block
\NIL\ return with values of
\VAR{result
}.
634 \IT{(
\SO*
{BLOCK
} \VAR{name
} \OPn{\VAR{form
}})
}
635 {Evaluate
\VAR{form
}s returning
636 \retval{values of last
\VAR{form
}} unless interrupted by
\SO{RETURN-FROM
}.
639 \IT{(
\SO*
{TAGBODY
} \Goos{\NEV{\VAR{tag
}}\XOR\VAR{form
}})
}
641 Evaluate
\VAR{form
}s.
\VAR{tag
}s (symbols or integers) are targets
642 for
\SO{GO
}. Return
\retval{\NIL}.
645 \IT{(
\SO*
{GO
} \VAR{tag
})
}
646 {Jump within a
\SO{tagbody
} to nearest
647 lexically enclosing
\kwd{eql
} \VAR{tag
}.
650 \IT{(
\SO*
{CATCH
} \VAR{tag
} \OPn{\VAR{form
}})
}
651 {Evaluate
\VAR{form
}s returning
652 \retval{values of last
\VAR{form
}} unless interrupted by
\SO{THROW
}.
655 \IT{(
\SO*
{THROW
} \VAR{tag
} \VAR{form
})
}
656 {Have the nearest dynamically
657 enclosing
\SO{CATCH
} with a tag
\FU{eq
} \VAR{tag
} return with the
658 values of
\VAR{form
}.
661 \IT{(
\FU*
{SLEEP
} \VAR{n
})
}
662 {Wait
\VAR{n
} seconds, return
\retval{\NIL}.
669 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
670 \subsection{Iteration
}
671 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
675 \IT{(
\xorGOO{\MC*
{DO
}\\
679 (
\VAR{var
} \OP{ \VAR{start
} \Op{\VAR{step
}}})
}{\
}^
{\!\!*
}})
680 (
\VAR{stop
} \OPn{\VAR{result
}})
681 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
682 \xorGOO{\NEV{\VAR{tag
}}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
684 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
}s successively bound according
685 to the values of the corresponding
\VAR{start
} and
\VAR{step
}
686 forms.
\VAR{var
}s are bound in parallel/sequentially, respectively.
687 Stop iteration when
\VAR{stop
} is
\T. Return
\retval{value of
691 \IT{(
\MC*
{DOTIMES
} (
\VAR{var
} \VAR{integer
} \Op{\VAR{result
}})
692 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
693 \Goos{\NEV{\VAR{tag
}}\XOR\VAR{form
}})
}
695 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
} successively bound
696 to integers from
0 to $
\mbox{\VAR{integer
}} -
1$. Upon evaluation of
697 \retval{\VAR{result
}},
\VAR{var
} is
\NIL.
700 \IT{(
\MC*
{DOLIST
}(
\VAR{var
} \VAR{list
} \Op{\VAR{result
}})
701 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
702 \Goos{\NEV{\VAR{tag
}}\XOR\VAR{form
}})
}
704 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
} successively bound
705 to the elements of
\VAR{list
}. Upon evaluation of
706 \retval{\VAR{result
}},
\VAR{var
} is
\NIL.
712 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
713 \subsection{Loop Facility
}
714 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
717 \label{loop-overview
}%
725 \text{\LKWD{named
} \VAR{n
}}
729 \text{\LKWD{with
} \VAR{var
} [\VAR{type
}] \LKWD{=
} \VAR{foo
}}
730 \
{\text{\LKWD{and
} \VAR{var-n
} [\VAR{type
}] \LKWD{=
} \VAR{bar
}\
}}^
{*
} \\
737 \text{\VAR{var
} [\VAR{type
}]}
745 \text{\LKWD{upfrom
}}\\
749 \text{\VAR{start
}\DF{\LIT{0}}}
761 \text{\LKWD{from
} \VAR{start
}}
764 \text{\LKWD{downto
}}\\
769 \text{\LKWD{downfrom
} \VAR{start
}}
773 \text{\LKWD{downto
}}\\
783 \text{\LKWD{by
} \VAR{step
}\DF{\LIT{1}}}
793 \text{\LKWD{by
} \VAR{form
}\DF{\kwd{cdr
}}}
795 \text{\LKWD{=
} \VAR{foo
}}
797 \text{\LKWD{then
} \VAR{bar
}}
799 \text{\LKWD{across
} \VAR{vector
}}\\
813 \text{\LKWD{hash-key
}}\\
814 \text{\LKWD{hash-keys
}}
825 \text{\LKWD{using
} (
\LKWD{hash-value
} \VAR{v
})
}
829 \text{\LKWD{hash-value
}}\\
830 \text{\LKWD{hash-values
}}
841 \text{\LKWD{using
} (
\LKWD{hash-key
} \VAR{k
})
}
847 \text{\LKWD{symbol
\Op{s
}}}\\
848 \text{\LKWD{present-symbol
\Op{s
}}}\\
849 \text{\LKWD{external-symbol
\Op{s
}}}
858 \right\
} \text{\VAR{package
}\DF{\V{*package*
}}}
863 \right\
}_
{\displaystyle{\mathbb{F
}_0
}}
866 \text{\LKWD{and
} }\boxed{\mathbb{F
}_i
}
870 \text{\LKWD{initially
}} \\
871 \text{\LKWD{finally
}}
874 \text{\VAR{form
}}^
{+
} \\
877 \right\
}^
{\!\!
\displaystyle{*
}}
881 \text{\LKWD{repeat
} \VAR{num
}}\\
884 \text{\LKWD{while
}}\\
885 \text{\LKWD{until
}}\\
886 \text{\LKWD{always
}}\\
887 \text{\LKWD{never
}}\\
888 \text{\LKWD{thereis
}}
901 \text{\VAR{form
}}^
{+
}\\
911 \text{\LKWD{collect
\Op{ing
}}}\\
912 \text{\LKWD{append
\Op{ing
}}}\\
913 \text{\LKWD{nconc
\Op{ing
}}}
921 \right\
} [\text{\LKWD{into
}\VAR{var
}}]\\
924 \text{\LKWD{count
\Op{ing
}}}\\
925 \text{\LKWD{sum
\Op{ming
}}}\\
926 \text{\LKWD{maximize
}}\\
927 \text{\LKWD{maximizing
}}\\
928 \text{\LKWD{minimize
}}\\
929 \text{\LKWD{minimizing
}}
938 [\text{\LKWD{into
}\VAR{n
}}]
939 [\text{\VAR{type
}}]\\
948 \boxed{\mathbb{S
}_i
}\
{\text{\LKWD{and
}}%
949 \boxed{\mathbb{S
}_j
}\
}^
{*
}[\text{\LKWD{else
}}%
950 \boxed{\mathbb{S
}_k
}\
{\text{\LKWD{and
}}%
951 \boxed{\mathbb{S
}_l
}\
}^
{*
}][\text{\LKWD{end
}}]
953 \right._
{\!\!\!\!
\displaystyle{\mathbb{S
}_0
}}
958 \text{\LKWD{initially
}} \\
959 \text{\LKWD{finally
}}
962 \text{\VAR{form
}}^
{+
}
964 \right\
}^
{\displaystyle{\!\!*
}}
968 \end{center
}\vspace{-
1em
}
969 \caption{Loop Facility, Overview.
}%
975 \IT{(
\MC*
{LOOP
} \OPn{\VAR{form
}})
}
977 Simple Loop. If
\VAR{form
}s do
978 not include any keywords of the Loop Facility, evaluate them forever.
981 \IT{(
\MC*
{LOOP
} \OPn{\VAR{form
}})
}
983 Loop Facility. If there are loop facility keywords in
\VAR{form
}s
984 see below and p.\
\pageref{loop-overview
}.
989 \IT{\LKWD*
{named
} \VAR{n
}}
991 Give implicit
\kwd{block
} of loop a name.
994 \IT{\LKWD*
{with
} \VAR{var
} \Op{\VAR{type
}} \LKWD*
{=
} \VAR{foo
} \Goos{\LKWD*
{and
}
995 \VAR{var-n
} \Op{\VAR{type
}} \LKWD*
{=
} \VAR{bar
}}}
997 Initialize local variables in parallel.
1000 \IT{\Goo{\LKWD*
{initially
}\XOR\LKWD*
{finally
}} \RP{\VAR{form
}}}
1002 Evaluate
\VAR{form
}s before begin, or after end, respectively, of iterations.
1005 \IT{\Goo{\LKWD*
{for
}\XOR\LKWD*
{as
}} \VAR{var
} \Op{\VAR{type
}}}
1007 Begin of iteration control clause.
1012 \IT{\Goo{\LKWD*
{upfrom
}\XOR\LKWD*
{from
}\XOR\LKWD*
{downfrom
}}
1015 Start stepping with
\VAR{start
}
1018 \IT{\Goo{\LKWD*
{upto
}\XOR\LKWD*
{downto
}\XOR\LKWD*
{to
}\XOR\LKWD*
{below
}\XOR\LKWD*
{above
}}
1021 Specify
\VAR{form
} as the end value for stepping.
1024 \IT{\Goo{\LKWD*
{in
}\XOR\LKWD*
{on
}} \VAR{list
}}
1026 Bind
\VAR{var
} to successive elements/tails, respectively, of
\VAR{list
}.
1029 \IT{\LKWD*
{by
} \Goo{\VAR{step
}\DF{\LIT{1}}\XOR\VAR{function
}\DF{\FU{cdr
}}}}
1031 Specify the (positive) decrement or increment or the
1032 \VAR{function
} to apply to the list.
1035 \IT{\LKWD*
{=
} \VAR{foo
} \Op{\LKWD*
{then
}
1036 \VAR{bar
}\DF{\VAR{foo
}}}}
1038 Bind
\VAR{var
} in the first iteration to
\VAR{foo
} and later to
\VAR{bar
}.
1041 \IT{\LKWD*
{across
} \VAR{vector
}}
1043 Bind
\VAR{var
} to successive elements of
\VAR{vector
}.
1046 \IT{\LKWD*
{being
} \Goo{\LKWD*
{the
}\XOR\LKWD*
{each
}}}
1048 Iterate over a hash table or a package.
1053 \IT{\Goo{\LKWD*
{hash-key
}\XOR\LKWD*
{hash-keys
}} \Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
1054 \Op{\LKWD*
{using
} (
\LKWD*
{hash-value
} \VAR{value
})
}}
1056 Bind
\VAR{var
} successively to the keys of
\VAR{hash-table
}; bind
\VAR{value
} to corresponding values.
1059 \IT{\Goo{\LKWD*
{hash-value
}\XOR\LKWD*
{hash-values
}} \Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
1060 \Op{\LKWD*
{using
} (
\LKWD*
{hash-key
} \VAR{key
})
}}
1062 Bind
\VAR{var
} successively to the values of
\VAR{hash-table
}; bind
\VAR{key
} to corresponding keys.
1065 \IT{\Goo{\LKWD*
{symbol
}\XOR\LKWD*
{symbols
}\XOR\LKWD*
{present-symbol
}\XOR\LKWD*
{present-symbols
}\XOR\LKWD*
{external-symbol
}\XOR\LKWD*
{external-symbols
}}
1066 \Op{\Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}}
1067 \VAR{package
}\DF{\V{*package*
}}}}
1069 Bind
\VAR{var
} successively to the symbols, or the present
1070 symbols, or the external symbols, respectively, of
1077 \IT{\LKWD*
{and
} \VAR{var
} \Op{\VAR{type
}}}
1079 Begin of another iteration control clause with variables
1080 initialized and stepped in parallel.
1083 \IT{\Goo{\LKWD*
{do
}\XOR\LKWD*
{doing
}} \RP{\VAR{form
}}}
1085 Evaluate
\VAR{form
}s in every iteration.
1090 Value of
\VAR{test
} form of an enclosing
\LKWD{if
},
1091 \LKWD{when
},
\LKWD{unless
}, or
\LKWD{else
} clause.
1094 \IT{\LKWD*
{return
} \Goo{\VAR{form
}\XOR\LKWD*
{it
}}}
1096 Return immediately with value of
\VAR{form
} or
\LKWD{it
}.
1099 \IT{\Goo{\LKWD*
{collect
}\XOR\LKWD*
{collecting
}}
1100 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
} \VAR{list
}}}
1102 Collect values of
\VAR{form
} or
\LKWD{it
} into
\VAR{list
}. If no
1103 \VAR{list
} is given, collect into an anonymous list which is
1104 returned after termination.
1107 \IT{\Goo{\LKWD*
{append
}\XOR\LKWD*
{appending
}\XOR\LKWD*
{nconc
}\XOR\LKWD*
{nconcing
}}
1108 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1111 Concatenate values of
\VAR{form
} or
\LKWD{it
}, which should be
1112 lists, into
\VAR{list
} by the means of
\FU{append
} or
\FU{nconc
},
1113 respectively. If no
\VAR{list
} is given, collect into an
1114 anonymous list which is returned after termination.
1117 \IT{\Goo{\LKWD*
{count
}\XOR\LKWD*
{counting
}}
1118 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1119 \VAR{n
}} \Op{\VAR{type
}}}
1121 Count the number of times the value of
\VAR{form
} or of
\LKWD{it
} is
\T.
1122 If no
\VAR{n
} is given, count into an anonymous variable
1123 which is returned after termination.
1126 \IT{\Goo{\LKWD*
{sum
}\XOR\LKWD*
{summing
}}
1127 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1128 \VAR{sum
}} \Op{\VAR{type
}}}
1130 Calculate the sum of the values of
\VAR{form
} or of
\LKWD{it
}.
1131 If no
\VAR{sum
} is given, sum into an anonymous variable
1132 which is returned after termination.
1135 \IT{\Goo{\LKWD*
{maximize
}\XOR\LKWD*
{maximizing
}\XOR
1136 \LKWD*
{minimize
}\XOR
1137 \LKWD*
{minimizing
}} \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1138 \VAR{max-min
}} \Op{\VAR{type
}}}
1140 Determine the maximum or minimum, respectively, of the values of
1141 \VAR{form
} or of
\LKWD{it
}.
1142 If no
\VAR{max-min
} is given, use an anonymous variable
1143 which is returned after termination.
1146 \IT{\Goo{\LKWD*
{if
}\XOR\LKWD*
{when
}\XOR\LKWD*
{unless
}} \VAR{ test
}
1147 \VAR{form-i
} \Goos{\LKWD*
{and
}
1148 \VAR{form-j
}} \Op{\LKWD*
{else
} \VAR{form-k
} \Goos{\LKWD*
{and
}
1149 \VAR{form-l
}}} \Op{\LKWD*
{end
}}}
1151 If
\VAR{test
} returns
\T,
\T, or
\NIL, respectively, evaluate
1152 \VAR{form-i
} and
\VAR{form-j
}s; otherwise, evaluate
\VAR{form-k
}
1153 and
\VAR{form-l
}s. Inside
\VAR{form-i
} and
\VAR{form-k
}, the value
1154 of
\VAR{test
} is accessible by
\LKWD*
{it
}.
1157 \IT{\LKWD*
{repeat
} \VAR{num
}}
1159 Terminate
\MC{loop
} after
\VAR{num
} times;
\VAR{num
} is evaluated once.
1162 \IT{\Goo{\LKWD*
{while
}\XOR\LKWD*
{until
}} \VAR{test
}}
1164 Continue iteration until
\VAR{test
} returns
\NIL, or
\T, respectively.
1167 \IT{\Goo{\LKWD*
{always
}\XOR\LKWD{never
}} \VAR{test
}}
1169 Terminate
\MC{loop
} returning
\NIL\ and skipping any
1170 \LKWD*
{finally
} parts as soon as
\VAR{test
} is
\NIL, or
\T,
1171 respectively. Otherwise continue
\MC{loop
} with its default return
1175 \IT{\LKWD*
{thereis
} \VAR{test
}}
1177 Terminate
\MC{loop
} when
\VAR{test
} is
\T\ and return value of
1178 \VAR{test
}, skipping any
\LKWD*
{finally
} parts. Otherwise continue
1179 \MC{loop
} with its default return value set to
\NIL.
1182 \IT{\LKWD*
{loop-finish
}}
1184 Terminate
\MC{loop
} immediately; skip any
\LKWD*
{finally
} parts.