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
\kwd{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{(
\kwd*
{DEFVAR
} \VAR{name
} \OP{\VAR{form
}
80 \Op{\VAR{documentation
}}})
}
82 Unless bound already, assign value of
\VAR{form
} to dynamic variable
86 \IT{(
\kwd*
{DEFPARAMETER
} \VAR{name
} \VAR{form
}
87 \Op{\VAR{documentation
}})
}
89 Assign value of
\VAR{form
} to dynamic variable
\retval{\VAR{name
}}.
92 \IT{(
\kwd*
{DEFCONSTANT
} \VAR{name
} \VAR{form
}
93 \Op{\VAR{documentation
}})
}
95 Assign value of
\VAR{form
} to global constant
\retval{\VAR{name
}}.
98 \IT{(
\xorGOO{\SF*
{SETF
}\\
99 \SF*
{PSETF
}}{\
}} \Goos{\VAR{place
}
102 Set
\VAR{place
}s to values of
\VAR{form
}s returning
\retval{value
103 of last
\VAR{form
}}. Work sequentially/in parallel, respectively.
106 \IT{(
\xorGOO{\SF*
{SETQ
}\\
107 \SF*
{PSETQ
}}{\
}} \Goos{\VAR{symbol
}
110 Set
\VAR{symbol
}s to values of
\VAR{form
}s returning
\retval{value
111 of last
\VAR{form
}}. Work sequentially/in parallel, respectively.
114 \IT{(
\FU*
{SET
} \VAR{symbol
} \VAR{foo
})
}
116 Set
\VAR{symbol
}'s value cell to
\retval{\VAR{foo
}}.
119 \IT{(
\SF*
{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{(
\SF*
{SHIFTF
} \RP{\VAR{place
}} \VAR{foo
})
}
127 Store valueof
\VAR{foo
} in rightmost
\VAR{place
} shifting values of
128 \VAR{place
}s left, returning
\retval{first
\VAR{place
}}.
131 \IT{(
\SF*
{ROTATEF
} \OPn{\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
} \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
} \VAR{ symbol
} \VAR{ key
})\\
163 (
\SF*
{REMF
} \VAR{ place
} \VAR{ key
})
}{.
}}
165 Remove fist 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, lambda list (
\OPn{\VAR{fu-arg
}}) has the form\\
181 \OP{\kwd*
{\&optional
} \Goos{\VAR{var
}\XOR(
\VAR{var
} \OP{\VAR{init
}
182 \Op{\VAR{supplied-p
}}})
}}
183 \Op{\kwd*
{\&rest
} \VAR{var
}}
184 \OP{\kwd*
{\&key
} \GOos{\VAR{var
}\XOR(
\Goo{\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
186 \OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}
187 \Op{\kwd*
{\&allow-other-keys
}}}
188 \OP{\kwd*
{\&aux
} \Goos{\VAR{var
}\XOR(
\VAR{var
} \Op{\VAR{init
}})
}}).\\
189 \VAR{supplied-p
} is
\T\ if there is a corresponding argument.
193 \IT{(
\xorGOO{\SF*
{DEFUN
} \VAR{ foo
}\\
\SF*
{LAMBDA
}}{\
}}
194 (
\VAR{\OPn{fu-arg
}})
\OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
195 \Op{\VAR{documentation
}}
198 Define function with
\retval{name
\VAR{foo
}} or an anonymous
199 function, respectively, which
200 applies
\VAR{form
}s to
\VAR{fu-arg
}s.
203 \IT{(
\xorGOO{\SF*
{FLET
}\\
207 \OPn{(
\kwd{declare
} \OPn{\VAR{local-decl
}})
}%
208 \Op{\VAR{documentation
}}
209 \OPn{\VAR{local-form
}})
})
\OPn{(
\kwd{declare
} \VAR{decl
})
}
212 Evaluate
\VAR{form
}s with
213 locally defined functions
\VAR{foo
}. Only for
\SF{LABELS
},
214 \VAR{foo
}s are visible inside
\VAR{local-forms
}. Return
215 \retval{values of
\VAR{form
}s
}.
218 \IT{(
\SF*
{FUNCTION
} \VAR{foo
})
}
219 {Return
\retval{function named
\VAR{foo
}}.
222 \IT{(
\FU*
{APPLY
} \VAR{function
} \RP{\VAR{arg
}})
}
224 Return
\retval{value of
\VAR{function
}} called on
225 \VAR{arg
}s. Last
\VAR{arg
} must be a list.
228 \IT{(
\FU*
{FUNCALL
} \VAR{function
} \OPn{arg
})
}
230 Return
\retval{value of
\VAR{function
}} called with
\VAR{arg
}s.
233 \IT{(
\SF*
{MULTIPLE-VALUE-CALL
} \VAR{foo
} \OPn{\VAR{form
}})
}
235 \VAR{foo
} with values of
\VAR{form
}s as its arguments. Return
236 \retval{values returned by
\VAR{foo
}}.
239 \IT{(
\FU*
{VALUES-LIST
} \VAR{list
})
}
241 Return
\retval{elements of
\VAR{list
}}.
244 \IT{(
\FU*
{VALUES
} \OPn{\VAR{foo
}})
}
246 Return
\retval{\VAR{foo
}s
} as multiple values.
\kwd{setf
}able.
249 \IT{(
\FU*
{MULTIPLE-VALUE-LIST
} \VAR{form
})
}
251 Return in a
\retval{list
} values of
\VAR{form
}.
254 \IT{(
\FU*
{NTH-VALUE
} \VAR{n
} \VAR{form
})
}
256 Zero-based
\retval{\VAR{n
}th return value
} of
\VAR{form
}.
259 \IT{(
\FU*
{COMPLEMENT
} \VAR{function
})
}
261 Return
\retval{new function
} with same arguments and same side effects
262 as
\VAR{function
}, but with complementary truth value.
265 \IT{(
\FU*
{CONSTANTLY
} \VAR{foo
})
}
267 Return
\retval{function
} of any number of arguments returning
\VAR{foo
}.
270 \IT{(
\FU*
{IDENTITY
} \VAR{foo
})
}
272 Return
\retval{\VAR{foo
}}.
275 \IT{(
\FU*
{FUNCTION-LAMBDA-EXPRESSION
} \VAR{function
})
}
277 If available, return
\retval{lambda expression
} of
\VAR{function
},
278 \retvalii{\NIL} if
\VAR{function
} was defined in an environment
279 without bindings, and
\retvaliii{name
} of
\VAR{function
}.
282 \IT{(
\FU*
{FDEFINITION
} \VAR{foo
})
}
284 \retval{Definition
} of function
\VAR{foo
}.
\kwd{setf
}able.
287 \IT{(
\FU*
{FMAKUNBOUND
} \VAR{foo
})
}
289 Remove global function or macro definition
\retval{\VAR{foo
}}.
292 \IT{\arrGOO{\CNS*
{CALL-ARGUMENTS-LIMIT
}\\
293 \CNS*
{LAMBDA-PARAMETERS-LIMIT
}}{.
}}
295 Upper bound of the number of function arguments or lambda list
296 parameters, respectively; $
\geq50$.
299 \IT{\CNS*
{MULTIPLE-VALUES-LIMIT
}}
301 Upper bound of the number of values a function can return; $
\geq20$.
307 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
311 Below, macro lambda list (
\OPn{\VAR{macro-arg
}}) has the form of either\\
312 (
\Op{\kwd*
{\&whole
} \VAR{var
}}
313 \Op{\kwd*
{\&environment
} \VAR{var
}}
315 \Op{\kwd*
{\&environment
} \VAR{var
}}
316 \Op{\kwd*
{\&optional
} \Goos{\VAR{var
}\XOR(
\VAR{var
} \OP{\VAR{init
}
317 \Op{\VAR{supplied-p
}}})
}}
318 \Op{\kwd*
{\&environment
} \VAR{var
}}
319 \Op{\Goo{\kwd*
{\&rest
}\XOR\kwd*
{\&body
}} \VAR{var
}}
320 \Op{\kwd*
{\&environment
} \VAR{var
}}
321 \OP{\kwd*
{\&key
} \GOos{\VAR{var
}\XOR(
\Goo{\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
323 \OP{\VAR{init
} \Op{\VAR{supplied-p
}}})
}%
324 \Op{\kwd*
{\&environment
} \VAR{var
}}
325 \Op{\kwd*
{\&allow-other-keys
}}}
326 \Op{\kwd*
{\&aux
} \Goos{\VAR{var
}\XOR(
\VAR{var
} \Op{\VAR{init
}})
}}
327 \Op{\kwd*
{\&environment
} \VAR{var
}})\\
329 (
\Op{\kwd*
{\&whole
} \VAR{var
}}
330 \Op{\kwd*
{\&environment
} \VAR{var
}}
332 \Op{\kwd*
{\&environment
} \VAR{var
}}
333 \Op{\kwd*
{\&optional
} \Goos{\VAR{var
}\XOR(
\VAR{var
} \OP{\VAR{init
}
334 \Op{\VAR{supplied-p
}}})
}}
335 \Op{\kwd*
{\&environment
} \VAR{var
}}
336 \kwd{.
} \VAR{var
}).\\
337 \kwd*
{\&environment
} \VAR{var
} may appear only once.
338 \VAR{supplied-p
} is
\T\ if there is a corresponding argument.
342 \IT{(
\xorGOO{\SF*
{DEFMACRO
}\\
\FU*
{DEFINE-COMPILER-MACRO
}}{\
}}
343 \VAR{foo
} (
\OPn{\VAR{macro-arg
}})
344 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
} \Op{\VAR{documentation
}}
347 Define macro
\retval{\VAR{foo
}}.
350 \IT{(
\SF*
{DEFINE-SYMBOL-MACRO
} \VAR{name
} \VAR{expansion-form
})
}
352 Make
\retval{\VAR{name
}} a macro call.
355 \IT{(
\SF*
{MACROLET
} (
\OPn{(
\VAR{name
} (
\OPn{\VAR{macro-arg
}})
356 \OPn{(
\kwd{declare
} \OPn{\VAR{local-decl
}})
}
357 \Op{\VAR{documentation
}} \OPn{\VAR{macro-form
}})
})
\OPn{(
\kwd{declare
}
358 \OPn{\VAR{decl
}})
} \OPn{\VAR{form
}})
}
360 Evaluate
\retval{\VAR{form
}s
} with
\VAR{name
}s locally defined
361 as macros which are invisible to each other.
364 \IT{(
\SF*
{SYMBOL-MACROLET
} (
\OPn{(
\VAR{name
}
365 \VAR{expansion-form
})
})
\OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
368 Evaluate
\retval{\VAR{form
}s
} with
\VAR{name
}s locally defined as
372 \IT{(
\SF*
{DEFSETF
} \VAR{function
} \xorGOO{\VAR{update
} \Op{\VAR{documentation
}}\\
373 \OPn{\VAR{arg
} (
\OPn{\VAR{var
}})
\text{ } \OPn{(
\kwd{declare
} \OPn{\VAR{
374 decl
}})
}\text{ } \Op{\VAR{documentation
}}}}{\
}})
}
376 Specify how to
\kwd{setf
} a place accessed by
377 \retval{\VAR{function
}}.
380 \IT{(
\SF*
{DEFINE-SETF-EXPANDER
} \VAR{function
} (
\OPn{\VAR{macro-arg
}})
381 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
} \Op{\VAR{documentation
}}
384 Specify how to
\kwd{setf
} a place accessed by
\retval{\VAR{function
}}.
387 \IT{(
\FU*
{GET-SETF-EXPANSION
} \VAR{place
} \Op{\VAR{environment
}})
}
389 Return five values describing how to
\kwd{setf
} place.
392 \IT{(
\SF*
{DEFINE-MODIFY-MACRO
} \VAR{foo
} (
\kwd{\&optional
}
393 \OPn{\VAR{var
}} \kwd{\&rest
} \OPn{\VAR{var
}})
\VAR{function
}
394 \Op{\VAR{documentation
}})
}
396 Define macro
\retval{\VAR{foo
}} able to read and write a place.
399 \IT{\CNS*
{LAMBDA-LIST-KEYWORDS
}}
400 {List of macro lambda list keywords.
406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
407 \subsection{Control Flow
}
408 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
411 \IT{(
\SF*
{IF
} \VAR{test
} \VAR{then
} \Op{\VAR{else
}\DF{\NIL}})
}
413 \retval{\VAR{then
}} if
\VAR{test
} returns
\T; return value of
414 \retval{\VAR{else
}} otherwise.
417 \IT{(
\SF*
{COND
} \OPn{(
\VAR{test
} \OPn{\VAR{then
}}\DF{\VAR{test
}})
})
}
419 Return the
\retval{values
} of the first
420 \VAR{then
}s whose
\VAR{test
} returns
\T; return
421 \retval{\NIL} if each
\VAR{test
} returns
\NIL.
424 \IT{(
\xorGOO{\SF*
{WHEN
}\\
425 \SF*
{UNLESS
}}{\
}} \VAR{test
}
426 \OPn{\VAR{foo
}}\DF{\NIL})
}
428 Evaluate
\VAR{foo
}s and return
\retval{values of last
\VAR{foo
}} if
429 \VAR{test
} returns
\T\ or
\NIL, respectively. Return
\retval{\NIL} otherwise.
432 \IT{(
\SF*
{CASE
} \VAR{test
} \OPn{(
\VAR{keys
} \OPn{\VAR{foo
}})
}
433 \Op{(
\Goo{\T\XOR\kwd*
{OTHERWISE
}} \OPn{\VAR{bar
}})
\DF{\NIL}})
}
435 Evaluate first
\VAR{foo
}s one of whose unevaluated
\VAR{keys
} is
436 \kwd{eql
} evaluated
\VAR{test
} and return
\retval{their values
}.
437 Return
\retval{values of
\VAR{bar
}s
} if no
\VAR{keys
} match.
440 \IT{(
\Goo{\SF*
{CCASE
}\XOR\SF*
{ECASE
}} \VAR{test
}
441 \OPn{(
\VAR{keys
} \OPn{\VAR{foo
}})
})
}
443 Evaluate first
\VAR{foo
}s one of whose unevaluated
\VAR{keys
} is
\kwd{eql
} evaluated
444 \VAR{test
} and return
\retval{their values
}. Signal correctible error/non-correctible
\kwd{type-error
},
445 respectively, if no
\VAR{keys
} match and return
\retval{\NIL} then.
448 \IT{(
\SF*
{AND
} \OPn{\VAR{form
}}\DF{\T})
}
450 Evaluate
\VAR{form
}s from left to
451 right. Immediately return
\retval{\NIL} if one
\VAR{form
}'s value is
\NIL. Return
452 \retval{values of last
\VAR{form
}} otherwise.
455 \IT{(
\SF*
{OR
} \OPn{\VAR{form
}}\DF{\NIL})
}
457 Evaluate
\VAR{form
}s from left to
458 right. Immediately return
\retval{primary value
} of first
459 non-
\NIL-evaluating form, or
\retval{all values
} if last
\VAR{form
}
460 is reached. Return
\retval{\NIL} if no
\VAR{form
} returns
\T.
463 \IT{(
\kwd*
{PROGN
} \OPn{\VAR{form
}}\DF{\NIL})
}
464 {Evaluate
\VAR{form
}s sequentially. Return
465 \retval{values of last
\VAR{form
}}.
468 \IT{(
\xorGOO{\SF*
{PROG
}\\
472 (
\VAR{var
} \Op{ \VAR{value
}})
}{\
}^
{\!\!*
}})
473 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
474 \xorGOO{\VAR{tag
}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
476 Evaluate
\kwd{TAGBODY
}-like body with
\VAR{var
}s locally bound (in parallel or sequentially, respectively) to
477 \VAR{value
}s. Return
\retval{\NIL} or explicitly
478 \retval{\kwd{return
}ed value
}.
482 (
\SF*
{MULTIPLE-VALUE-PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
483 (
\SF*
{PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
484 (
\SF*
{PROG2
} \VAR{ form-a
} \VAR{ form-r
} \OPn{\VAR{ form
}})
}{.
}}
486 Evaluate forms in order. Return
\retval{values/
1st value
},
487 respectively, of
\VAR{form-r
}.
490 \IT{(
\SF*
{PROGV
} \VAR{symbols
} \VAR{values
} \OPn{\VAR{form
}})
}
492 Evaluate
\VAR{form
}s with
\VAR{symbols
} dynamically bound to
\VAR{values
} or
493 \NIL. Return
\retval{values returned by
\VAR{form
}s
}.
496 \IT{(
\SF*
{DESTRUCTURING-BIND
} \VAR{foo
} \VAR{bar
} \OPn{(
\kwd{declare
}
497 \OPn{\VAR{decl
}})
} \OPn{\VAR{form
}})
}
499 Evaluate
\VAR{form
}s, and return
\retval{values of last
\VAR{form
}},
500 with variables from tree
\VAR{foo
} bound to corresponding elements
504 \IT{(
\kwd*
{MULTIPLE-VALUE-BIND
} (
\OPn{\VAR{var
}})
\VAR{values-form
}
505 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
} \OPn{\VAR{body-form
}})
}
507 \VAR{body-form
}s with
\VAR{var
}s bound to the return values of
508 \VAR{values-form
}. Return
\retval{values returned by
\VAR{body-form
}s
}.
511 \IT{(
\xorGOO{\SF*
{LET
}\\
514 (
\VAR{name
}\Op{\VAR{value
}})
}{\
}^
{\!\!*
}})
515 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
518 Evaluate
\VAR{form
}s with
\VAR{name
}s bound (in parallel or
519 sequentially, respectively) to
\VAR{value
}s or
\NIL. Return
520 \retval{values of
\VAR{form
}s
}.
523 \IT{(
\SF*
{LOCALLY
} \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
526 Evaluate
\VAR{form
}s with declarations
\VAR{decl
} in
527 effect. Return
\retval{values of
\VAR{form
}s
}.
530 \IT{(
\SF*
{RETURN-FROM
} \VAR{foo
} \Op{\VAR{result
}\DF{\NIL}})
}
532 Have nearest enclosing
\kwd{block
} \VAR{foo
} return with
533 values of
\VAR{result
}.
536 \IT{(
\SF*
{RETURN
} \Op{\VAR{result
}\DF{\NIL}})
}
538 Have nearest enclosing block
\NIL\ return with values of
\VAR{result
}.
541 \IT{(
\SF*
{BLOCK
} \VAR{name
} \OPn{\VAR{form
}})
}
542 {Evaluate
\VAR{form
}s returning
543 \retval{values of last
\VAR{form
}} unless interrupted by
\SF{RETURN-FROM
}.
546 \IT{(
\SF*
{TAGBODY
} \Goos{\VAR{tag
}\XOR\VAR{form
}})
}
548 Evaluate
\VAR{form
}s.
\VAR{tag
}s (symbols or integers) are targets
549 for
\SF{GO
}. Return
\retval{\NIL}.
552 \IT{(
\SF*
{GO
} \VAR{tag
})
}
553 {Jump within a
\SF{tagbody
} to nearest
554 lexically enclosing
\kwd{eql
} \VAR{tag
}.
557 \IT{(
\SF*
{CATCH
} \VAR{tag
} \OPn{\VAR{form
}})
}
558 {Evaluate
\VAR{form
}s returning
559 \retval{values of last
\VAR{form
}} unless interrupted by
\SF{THROW
}.
562 \IT{(
\SF*
{THROW
} \VAR{tag form
})
}
563 {Have the nearest dynamically
564 enclosing
\SF{CATCH
} with a tag
\kwd{eq
} \VAR{tag
} return with the
565 values of
\VAR{form
}.
568 \IT{(
\FU*
{SLEEP
} \VAR{n
})
}
569 {Wait
\VAR{n
} seconds, return
\retval{\NIL}.
576 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
577 \subsection{Iteration
}
578 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582 \IT{(
\xorGOO{\SF*
{DO
}\\
\SF*
{DO*
}}{\
}}
585 (
\VAR{var
} \Op{ \VAR{start
} \Op{\VAR{step
}}})
}{\
}^
{\!\!*
}})
586 (
\VAR{stop
} \OPn{\VAR{result
}})
587 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
588 \xorGOO{\VAR{tag
}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
590 Evaluate
\SF{TAGBODY
}-like body with
\VAR{var
}s successively bound according
591 to the values of the corresponding
\VAR{start
} and
\VAR{step
}
592 forms.
\VAR{var
}s are bound in parallel/sequentially, respectively.
593 Stop iteration when
\VAR{stop
} is
\T. Return
\retval{value of
597 \IT{(
\SF*
{DOTIMES
} (
\VAR{var
} \VAR{integer
} \Op{\VAR{result
}})
598 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
599 \Goos{\VAR{tag
}\XOR\VAR{form
}})
}
601 Evaluate
\SF{TAGBODY
}-like body with
\VAR{var
} successively bound
602 to integers from
0 to $
\mbox{\VAR{integer
}} -
1$. Upon evaluation of
603 \retval{\VAR{result
}},
\VAR{var
} is
\NIL.
606 \IT{(
\SF*
{DOLIST
}(
\VAR{var
} \VAR{list
} \Op{\VAR{result
}})
607 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
608 \Goos{\VAR{tag
}\XOR\VAR{form
}})
}
610 Evaluate
\SF{TAGBODY
}-like body with
\VAR{var
} successively bound
611 to the elements of
\VAR{list
}. Upon evaluation of
612 \retval{\VAR{result
}},
\VAR{var
} is
\NIL.
618 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 \subsection{Loop Facility
}
620 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
623 \label{loop-overview
}%
631 \text{\LKWD{named
} \VAR{n
}}
635 \text{\LKWD{with
} \VAR{var
} [\VAR{type
}] \LKWD{=
} \VAR{foo
}}
636 \
{\text{\LKWD{and
} \VAR{var-n
} [\VAR{type
}] \LKWD{=
} \VAR{bar
}\
}}^
{*
} \\
643 \text{\VAR{var
} [\VAR{type
}]}
651 \text{\LKWD{upfrom
}}\\
655 \text{\VAR{start
}\DF{0}}
667 \text{\LKWD{from
} \VAR{start
}}
670 \text{\LKWD{downto
}}\\
675 \text{\LKWD{downfrom
} \VAR{start
}}
679 \text{\LKWD{downto
}}\\
689 \text{\LKWD{by
} \VAR{step
}\DF{1}}
699 \text{\LKWD{by
} \VAR{form
}\DF{\kwd{cdr
}}}
701 \text{\LKWD{=
} \VAR{foo
}}
703 \text{\LKWD{then
} \VAR{bar
}}
705 \text{\LKWD{across
} \VAR{vector
}}\\
719 \text{\LKWD{hash-key
}}\\
720 \text{\LKWD{hash-keys
}}
731 \text{\LKWD{using
} (
\LKWD{hash-value
} \VAR{v
})
}
735 \text{\LKWD{hash-value
}}\\
736 \text{\LKWD{hash-values
}}
747 \text{\LKWD{using
} (
\LKWD{hash-key
} \VAR{k
})
}
753 \text{\LKWD{symbol
\Op{s
}}}\\
754 \text{\LKWD{present-symbol
\Op{s
}}}\\
755 \text{\LKWD{external-symbol
\Op{s
}}}
764 \right\
} \text{\VAR{package
}\DF{\V{*package*
}}}
769 \right\
}_
{\displaystyle{\mathbb{F
}_0
}}
772 \text{\LKWD{and
} }\boxed{\mathbb{F
}_i
}
776 \text{\LKWD{initially
}} \\
777 \text{\LKWD{finally
}}
780 \text{\VAR{form
}}^
{+
} \\
783 \right\
}^
{\!\!
\displaystyle{*
}}
787 \text{\LKWD{repeat
} \VAR{num
}}\\
790 \text{\LKWD{while
}}\\
791 \text{\LKWD{until
}}\\
792 \text{\LKWD{always
}}\\
793 \text{\LKWD{never
}}\\
794 \text{\LKWD{thereis
}}
807 \text{\VAR{form
}}^
{+
}\\
817 \text{\LKWD{collect
\Op{ing
}}}\\
818 \text{\LKWD{append
\Op{ing
}}}\\
819 \text{\LKWD{nconc
\Op{ing
}}}
827 \right\
} [\text{\LKWD{into
}\VAR{var
}}]\\
830 \text{\LKWD{count
\Op{ing
}}}\\
831 \text{\LKWD{sum
\Op{ming
}}}\\
832 \text{\LKWD{maximize
}}\\
833 \text{\LKWD{maximizing
}}\\
834 \text{\LKWD{minimize
}}\\
835 \text{\LKWD{minimizing
}}
844 [\text{\LKWD{into
}\VAR{n
}}]
845 [\text{\VAR{type
}}]\\
854 \boxed{\mathbb{S
}_i
}\
{\text{\LKWD{and
}}%
855 \boxed{\mathbb{S
}_j
}\
}^
{*
}[\text{\LKWD{else
}}%
856 \boxed{\mathbb{S
}_k
}\
{\text{\LKWD{and
}}%
857 \boxed{\mathbb{S
}_l
}\
}^
{*
}][\text{\LKWD{end
}}]
859 \right._
{\!\!\!\!
\displaystyle{\mathbb{S
}_0
}}
864 \text{\LKWD{initially
}} \\
865 \text{\LKWD{finally
}}
868 \text{\VAR{form
}}^
{+
}
870 \right\
}^
{\displaystyle{\!\!*
}}
874 \end{center
}\vspace{-
1em
}
875 \caption{Loop Facility, Overview.
}%
881 \IT{(
\SF*
{LOOP
} \OPn{\VAR{form
}})
}
883 Simple Loop. If
\VAR{form
}s do
884 not include any keywords of the Loop Facility, evaluate them forever.
887 \IT{(
\SF*
{LOOP
} \OPn{\VAR{form
}})
}
889 Loop Facility. If there are loop facility keywords in
\VAR{form
}s
890 see below and p.\
\pageref{loop-overview
}.
895 \IT{\LKWD*
{named
} \VAR{n
}}
897 Give implicit
\kwd{block
} of loop a name.
900 \IT{\LKWD*
{with
} \VAR{var
} \Op{\VAR{type
}} \LKWD*
{=
} \VAR{foo
} \Goos{\LKWD*
{and
}
901 \VAR{var-n
} \Op{\VAR{type
}} \LKWD*
{=
} \VAR{bar
}}}
903 Initialize local variables in parallel.
906 \IT{\Goo{\LKWD*
{initially
}\XOR\LKWD*
{finally
}} \RP{\VAR{form
}}}
908 Evaluate
\VAR{form
}s before begin, or after end, respectively, of iterations.
911 \IT{\Goo{\LKWD*
{for
}\XOR\LKWD*
{as
}} \VAR{var
} \Op{\VAR{type
}}}
913 Begin of iteration control clause.
918 \IT{\Goo{\LKWD*
{upfrom
}\XOR\LKWD*
{from
}\XOR\LKWD*
{downfrom
}}
921 Start stepping with
\VAR{start
}
924 \IT{\Goo{\LKWD*
{upto
}\XOR\LKWD*
{downto
}\XOR\LKWD*
{to
}\XOR\LKWD*
{below
}\XOR\LKWD*
{above
}}
927 Specify
\VAR{form
} as the end value for stepping.
930 \IT{\Goo{\LKWD*
{in
}\XOR\LKWD*
{on
}} \VAR{list
}}
932 Bind
\VAR{var
} to successive elements/tails, respectively, of
\VAR{list
}.
935 \IT{\LKWD*
{by
} \Goo{\VAR{step
}\DF{1}\XOR\VAR{function
}\DF{\kwd{cdr
}}}}
937 Specify the (positive) decrement or increment or the
938 \VAR{function
} to apply to the list.
941 \IT{\LKWD*
{=
} \VAR{foo
} \Op{\LKWD*
{then
}
942 \VAR{bar
}\DF{\VAR{foo
}}}}
944 Bind
\VAR{var
} in the first iteration to
\VAR{foo
} and later to
\VAR{bar
}.
947 \IT{\LKWD*
{across
} \VAR{vector
}}
949 Bind
\VAR{var
} to successive elements of
\VAR{vector
}.
952 \IT{\LKWD*
{being
} \Goo{\LKWD*
{the
}\XOR\LKWD*
{each
}}}
954 Iterate over a hash table or a package.
959 \IT{\Goo{\LKWD*
{hash-key
}\XOR\LKWD*
{hash-keys
}} \Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
960 \Op{\LKWD*
{using
} (
\LKWD*
{hash-value
} \VAR{value
})
}}
962 Bind
\VAR{var
} successively to the keys of
\VAR{hash-table
}; bind
\VAR{value
} to corresponding values.
965 \IT{\Goo{\LKWD*
{hash-value
}\XOR\LKWD*
{hash-values
}} \Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
966 \Op{\LKWD*
{using
} (
\LKWD*
{hash-key
} \VAR{key
})
}}
968 Bind
\VAR{var
} successively to the values of
\VAR{hash-table
}; bind
\VAR{key
} to corresponding keys.
971 \IT{\Goo{\LKWD*
{symbol
}\XOR\LKWD*
{symbols
}\XOR\LKWD*
{present-symbol
}\XOR\LKWD*
{present-symbols
}\XOR\LKWD*
{external-symbol
}\XOR\LKWD*
{external-symbols
}}
972 \Op{\Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}}
973 \VAR{package
}\DF{\V{*package*
}}}}
975 Bind
\VAR{var
} successively to the symbols, or the present symbols, or the external symbols, respectively, of
\VAR{package
}.
981 \IT{\LKWD*
{and
} \VAR{var
} \Op{\VAR{type
}}}
983 Begin of another iteration control clause with variables initialized and stepped in parallel.
986 \IT{\Goo{\LKWD*
{do
}\XOR\LKWD*
{doing
}} \RP{\VAR{form
}}}
988 Evaluate
\VAR{form
}s in every iteration.
993 Value of the test form of an enclosing
\LKWD{if
},
\LKWD{when
},
994 or
\LKWD{unless
} clause.
997 \IT{\LKWD*
{return
} \Goo{\VAR{form
}\XOR\LKWD*
{it
}}}
999 Return immediately with value of
\VAR{form
} or
\LKWD{it
}.
1002 \IT{\Goo{\LKWD*
{collect
}\XOR\LKWD*
{collecting
}}
1003 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
} \VAR{list
}}}
1005 Collect values of
\VAR{form
} or
\LKWD{it
} into
\VAR{list
}. If no
\VAR{list
} is given, collect into an anonymous list
1006 which is returned after termination.
1009 \IT{\Goo{\LKWD*
{append
}\XOR\LKWD*
{appending
}\XOR\LKWD*
{nconc
}\XOR\LKWD*
{nconcing
}}
1010 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1013 Concatenate values of
\VAR{form
} or
\LKWD{it
}, which should be lists, into
\VAR{list
} by the means of
\FU{append
}
1014 or
\FU{nconc
}, respectively. If no
\VAR{list
} is given, collect into an anonymous list
1015 which is returned after termination.
1018 \IT{\Goo{\LKWD*
{count
}\XOR\LKWD*
{counting
}}
1019 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1020 \VAR{n
}} \Op{\VAR{type
}}}
1022 Count the number of times the value of
\VAR{form
} or of
\LKWD{it
} is
\T.
1023 If no
\VAR{n
} is given, count into an anonymous variable
1024 which is returned after termination.
1027 \IT{\Goo{\LKWD*
{sum
}\XOR\LKWD*
{summing
}}
1028 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1029 \VAR{sum
}} \Op{\VAR{type
}}}
1031 Calculate the sum of the values of
\VAR{form
} or of
\LKWD{it
}.
1032 If no
\VAR{sum
} is given, sum into an anonymous variable
1033 which is returned after termination.
1036 \IT{\Goo{\LKWD*
{maximize
}\XOR\LKWD*
{maximizing
}\XOR
1037 \LKWD*
{minimize
}\XOR
1038 \LKWD*
{minimizing
}} \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1039 \VAR{max-min
}} \Op{\VAR{type
}}}
1041 Determine the maximum or minimum, respectively, of the values of
1042 \VAR{form
} or of
\LKWD{it
}.
1043 If no
\VAR{max-min
} is given, use an anonymous variable
1044 which is returned after termination.
1047 \IT{\Goo{\LKWD*
{if
}\XOR\LKWD*
{when
}\XOR\LKWD*
{unless
}} \VAR{ test
}
1048 \VAR{form-i
} \Goos{\LKWD*
{and
}
1049 \VAR{form-j
}} \Op{\LKWD*
{else
} \VAR{form-k
} \Goos{\LKWD*
{and
}
1050 \VAR{form-l
}}} \Op{\LKWD*
{end
}}}
1052 If
\VAR{test
} returns
\T,
\T, or
\NIL, respectively, evaluate
1053 \VAR{form-i
} and
\VAR{form-j
}s; otherwise, evaluate
\VAR{form-k
}
1054 and
\VAR{form-l
}s. Inside
\VAR{form-i
} and
\VAR{form-k
}, the value
1055 of
\VAR{test
} is accessible by
\LKWD*
{it
}.
1058 \IT{\LKWD*
{repeat
} \VAR{num
}}
1060 Terminate
\SF{loop
} after
\VAR{num
} times;
\VAR{num
} is evaluated once.
1063 \IT{\Goo{\LKWD*
{while
}\XOR\LKWD*
{until
}} \VAR{test
}}
1065 Continue iteration until
\VAR{test
} returns
\NIL, or
\T, respectively.
1068 \IT{\Goo{\LKWD*
{always
}\XOR\LKWD{never
}} \VAR{test
}}
1070 Terminate
\SF{loop
} returning
\NIL\ and skipping any
1071 \LKWD*
{finally
} parts as soon as
\VAR{test
} is
\NIL, or
\T,
1072 respectively. Otherwise continue
\SF{loop
} with its default return
1076 \IT{\LKWD*
{thereis
} \VAR{test
}}
1078 Terminate
\SF{loop
} when
\VAR{test
} is
\T\ and return value of
1079 \VAR{test
}, skipping any
\LKWD*
{finally
} parts. Otherwise continue
1080 \SF{loop
} with its default return value set to
\NIL.
1083 \IT{\LKWD*
{loop-finish
}}
1085 Terminate
\SF{loop
} immediately; skip any
\LKWD*
{finally
} parts.