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
\kwd{character
}, or
\kwd{number
}s of the
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 equivalant
\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
\kwd{class
} with
46 \kwd{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
\kwd{equalp
} elements.
51 \IT{(
\FU*
{NOT
} \VAR{bool
})
}
53 \retval{\NIL} if
\VAR{bool
} is
\T;
\retval{\T} if
\VAR{bool
} is
\NIL.
56 \IT{(
\FU*
{BOUNDP
} \VAR{symbol
})
}
58 \retval{\T} if
\VAR{symbol
} is a special variable.
61 \IT{(
\FU*
{CONSTANTP
} \VAR{foo
} \Op{\VAR{environment
}})
}
63 \retval{\T} if
\VAR{foo
} is a constant form.
66 \IT{(
\FU*
{FUNCTIONP
} \VAR{foo
})
}
68 \retval{\T} if
\VAR{foo
} is of type
\kwd{function
}.
71 \IT{(
\FU*
{FBOUNDP
} \VAR{foo
})
}
73 \retval{\T} if
\VAR{foo
} is a global function or macro.
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 \subsection{Variables
}
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 \MC*
{DEFPARAMETER
}}{\
}} \NEV{\VAR{foo
}} \VAR{form
}
89 \Op{\NEV{\VAR{doc
}}})
}
91 Assign value of
\VAR{form
} to global constant/dynamic variable
\retval{\VAR{foo
}}.
94 \IT{(
\MC*
{DEFVAR
} \NEV{\VAR{foo
}} \OP{\VAR{form
}
95 \Op{\NEV{\VAR{doc
}}}})
}
97 Unless bound already, assign value of
\VAR{form
} to dynamic variable
101 \IT{(
\xorGOO{\MC*
{SETF
}\\
102 \MC*
{PSETF
}}{\
}} \Goos{\VAR{place
}
105 Set
\VAR{place
}s to values of
\VAR{form
}s. Return
\retval{value
106 of last
\VAR{form
}}. Work sequentially/in parallel, respectively.
109 \IT{(
\xorGOO{\SO*
{SETQ
}\\
110 \MC*
{PSETQ
}}{\
}} \Goos{\VAR{symbol
}
113 Set
\VAR{symbol
}s to values of
\VAR{form
}s. Return
\retval{value
114 of last
\VAR{form
}}. Work sequentially/in parallel, respectively.
117 \IT{(
\FU*
{SET
} \DES{\VAR{symbol
}} \VAR{foo
})
}
119 Set
\VAR{symbol
}'s value cell to
\retval{\VAR{foo
}}. Deprecated.
122 \IT{(
\MC*
{MULTIPLE-VALUE-SETQ
} \VAR{vars
} \VAR{form
})
}
124 Set elements of
\VAR{vars
} to the values of
125 \VAR{form
}. Return
\retval{\VAR{form
}'s primary value
}.
128 \IT{(
\MC*
{SHIFTF
} \RP{\DES{\VAR{place
}}} \VAR{foo
})
}
130 Store value of
\VAR{foo
} in rightmost
\VAR{place
} shifting values of
131 \VAR{place
}s left, returning
\retval{first
\VAR{place
}}.
134 \IT{(
\MC*
{ROTATEF
} \OPn{\DES{\VAR{place
}}})
}
136 Rotate values of
\VAR{place
}s left, old first becoming new last
137 \VAR{place
}'s value. Return
\retval{\NIL}.
140 \IT{(
\FU*
{MAKUNBOUND
} \DES{\VAR{foo
}})
}
142 Delete special variable
\retval{\VAR{foo
}} if any.
145 \label{:property_lists
}
146 \IT{\arrGOO{(
\FU*
{GET
} \VAR{ symbol
} \VAR{ key
}
147 \OP{\VAR{default
}\DF{\NIL}})\\
148 (
\FU*
{GETF
} \VAR{ place
} \VAR{ key
}
149 \OP{\VAR{default
}\DF{\NIL}})
}{.
}}
151 \retval{First entry
\VAR{key
}} from property list stored in
152 \VAR{symbol
}/in
\VAR{place
}, respectively, or
\retval{\VAR{default
}} if
153 there was no
\VAR{key
}.
\kwd{setf
}able.
156 \IT{(
\FU*
{GET-PROPERTIES
} \VAR{property-list
} \VAR{keys
})
}
158 Return
\retval{key
} and
\retvalii{value
} of first entry from
\VAR{property-list
}
159 matching a key from
\VAR{keys
}, and
\retvaliii{tail of
160 \VAR{property-list
}} starting with that key. Return
\retval{\NIL},
161 \retvalii{\NIL}, and
\retvaliii{\NIL} if there was no matching key
162 in
\VAR{property-list
}.
165 \IT{\arrGOO{(
\FU*
{REMPROP
} \DES{\VAR{symbol
}} \VAR{ key
})\\
166 (
\MC*
{REMF
} \DES{\VAR{place
}} \VAR{ key
})
}{.
}}
168 Remove first entry
\VAR{key
} from property list stored in
169 \VAR{symbol
}/in
\VAR{place
}, respectively. Return
\retval{\T} if
\VAR{key
}
170 was there, or
\retval{\NIL} otherwise.
176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177 \subsection{Functions
}
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
179 \label{section:Functions
}
182 Below, ordinary lambda list (
\OPn{\VAR{ord-$
\lambda$
}}) has the form\\
183 % \VAR{var} referenced from DEFSTRUCT
185 \OP{\kwd*
{\&optional
} \xorGOO{%
187 (
\VAR{var
} \OP{\VAR{init
}\DF{\NIL}\text{ } \Op{\VAR{supplied-p
}}})
}{\
}}}
189 \Op{\kwd*
{\&rest
} \VAR{var
}}
191 \OP{\kwd*
{\&key
} \xorGOO{%
195 (
\kwd{:
}\VAR{key
} \VAR{var
})
}{\
}}
196 \text{ }\OP{\VAR{init
}\DF{\NIL}\text{ }\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
198 \Op{\kwd*
{\&allow-other-keys
}}}
200 \OP{\kwd*
{\&aux
} \xorGOO{%
202 (
\VAR{var
} \Op{\VAR{init
}\DF{\NIL}})
}{\
}}}).\\
203 \VAR{supplied-p
} is
\T\ if there is a corresponding
204 argument.
\VAR{init
} forms can refer to any
\VAR{init
} and
205 \VAR{supplied-p
} to their left.
210 \IT{(
\xorGOO{\MC*
{DEFUN
}\xorGOO{\VAR{foo
}\\%FIXME:BLOCK
211 (
\kwd{setf
} \VAR{ foo
})
}{.
}\\
213 (
\VAR{\OPn{ord-$
\lambda$
}})
\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
217 Define a function named
\retval{\VAR{foo
}} or
\retval{(
\kwd{setf
}
218 \VAR{foo
})
}, or an anonymous
\retval{function
}, respectively, which applies
219 \VAR{form
}s to
\VAR{ord-$
\lambda$
}s.
222 \IT{(
\xorGOO{\SO*
{FLET
}\\
223 \SO*
{LABELS
}}{\
}} %FIXME:BLOCK
225 (
\OPn{\VAR{ord-$
\lambda$
}})
226 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{local-decl
}}})
}%
228 \PROGN{\VAR{local-form
}})
})
\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
231 Evaluate
\VAR{form
}s with
232 locally defined functions
\VAR{foo
}. Only for
\SO{LABELS
},
233 \VAR{foo
}s are visible inside
\VAR{local-forms
}. Return
234 \retval{values of
\VAR{form
}s
}.
237 \IT{(
\SO*
{FUNCTION
} \xorGOO{%
239 (
\MC{lambda
} \OPn{\VAR{form
}})
}{\
}})
}
241 Return lexically innermost
\retval{function
} named
\VAR{foo
} or a
242 lexical closure of the
\retval{\MC{lambda
} expression
}.
245 \IT{(
\FU*
{APPLY
} \VAR{function
} \RP{\VAR{arg
}})
}
247 Return
\retval{values of
\VAR{function
}} called on
248 \VAR{arg
}s. Last
\VAR{arg
} must be a list.
251 \IT{(
\FU*
{FUNCALL
} \VAR{function
} \OPn{arg
})
}
253 Return
\retval{values of
\VAR{function
}} called with
\VAR{arg
}s.
256 \IT{(
\SO*
{MULTIPLE-VALUE-CALL
} \VAR{foo
} \OPn{\VAR{form
}})
}
258 \VAR{foo
} with all the values of each
\VAR{form
} as its arguments. Return
259 \retval{values returned by
\VAR{foo
}}.
262 \IT{(
\FU*
{VALUES-LIST
} \VAR{list
})
}
264 Return
\retval{elements of
\VAR{list
}}.
267 \IT{(
\FU*
{VALUES
} \OPn{\VAR{foo
}})
}
269 Return as multiple values the
\retval{primary values
} of the
270 \VAR{foo
}s.
\kwd{setf
}able.
273 \IT{(
\FU*
{MULTIPLE-VALUE-LIST
} \VAR{form
})
}
275 Return in a
\retval{list
} values of
\VAR{form
}.
278 \IT{(
\FU*
{NTH-VALUE
} \VAR{n
} \VAR{form
})
}
280 Zero-indexed
\retval{\VAR{n
}th return value
} of
\VAR{form
}.
283 \IT{(
\FU*
{COMPLEMENT
} \VAR{function
})
}
285 Return
\retval{new function
} with same arguments and same side effects
286 as
\VAR{function
}, but with complementary truth value.
289 \IT{(
\FU*
{CONSTANTLY
} \VAR{foo
})
}
291 Return
\retval{function
} of any number of arguments returning
\VAR{foo
}.
294 \IT{(
\FU*
{IDENTITY
} \VAR{foo
})
}
296 Return
\retval{\VAR{foo
}}.
299 \IT{(
\FU*
{FUNCTION-LAMBDA-EXPRESSION
} \VAR{function
})
}
301 If available, return
\retval{lambda expression
} of
\VAR{function
},
302 \retvalii{\NIL} if
\VAR{function
} was defined in an environment
303 without bindings, and
\retvaliii{name
} of
\VAR{function
}.
306 \IT{(
\FU*
{FDEFINITION
} \VAR{foo
})
}
308 \retval{Definition
} of function
\VAR{foo
}.
\kwd{setf
}able.
311 \IT{(
\FU*
{FMAKUNBOUND
} \VAR{foo
})
}
313 Remove global function or macro definition
\retval{\VAR{foo
}}.
316 \IT{\arrGOO{\CNS*
{CALL-ARGUMENTS-LIMIT
}\\
317 \CNS*
{LAMBDA-PARAMETERS-LIMIT
}}{.
}}
319 Upper bound of the number of function arguments or lambda list
320 parameters, respectively; $
\geq50$.
323 \IT{\CNS*
{MULTIPLE-VALUES-LIMIT
}}
325 Upper bound of the number of values a function can return; $
\geq20$.
331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
334 \label{section:Macros
}
337 Below, macro lambda list (
\OPn{\VAR{macro-$
\lambda$
}}) has the form of
340 (
\Op{\kwd*
{\&whole
} \VAR{var
}}
346 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}^
{\!\!*
}}
350 \Op{\kwd*
{\&optional
}
355 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}\text{ }
356 \OP{\VAR{init
}\DF{\NIL}\text{ } \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
366 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}}
375 (
\kwd{:
}\VAR{key
} \xorGOO{%
377 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}})
}{\
}}
378 \text{ }\OP{\VAR{init
}\DF{\NIL}\text{ } \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
380 \Op{\kwd*
{\&allow-other-keys
}}}
385 (
\VAR{var
} \Op{\VAR{init
}\DF{\NIL}})
}{\
}^
{\!\!*
}}}
398 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}^
{\!\!*
}}
402 \Op{\kwd*
{\&optional
}
407 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}\text{ }
408 \OP{\VAR{init
}\DF{\NIL}\text{ } \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
414 One toplevel
\Op{\VAR{E
}} may be replaced by
\kwd*
{\&environment
}
415 \VAR{var
}.
\VAR{supplied-p
} is
\T\ if there is a corresponding
421 \IT{(
\xorGOO{\MC*
{DEFMACRO
}\\%FIXME:BLOCK
422 \FU*
{DEFINE-COMPILER-MACRO
}}{\
}}
423 \VAR{foo
} (
\OPn{\VAR{macro-$
\lambda$
}})
424 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
} \Op{\NEV{\VAR{doc
}}}
427 Define macro
\retval{\VAR{foo
}} which on evaluation as (
\VAR{foo
}
428 \VAR{tree
}) applies expanded
\VAR{form
}s to arguments from
429 \VAR{tree
} which corresponds to
\VAR{tree
}-shaped
430 \VAR{macro-$
\lambda$
}s.
433 \IT{(
\MC*
{DEFINE-SYMBOL-MACRO
} \VAR{foo
} \VAR{form
})
}
435 Define symbol macro
\retval{\VAR{foo
}} which on evaluation evaluates
439 \IT{(
\SO*
{MACROLET
} (
\OPn{(
\VAR{foo
} (
\OPn{\VAR{macro-$
\lambda$
}})
%FIXME:BLOCK
440 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{local-decl
}}})
}
441 \Op{\NEV{\VAR{doc
}}} \PROGN{\VAR{macro-form
}})
})
\OPn{(
\kwd{declare
}
442 \OPn{\NEV{\VAR{decl
}}})
} \PROGN{\VAR{form
}})
}
444 Evaluate
\retval{\VAR{form
}s
} with locally defined mutually
445 invisible macros
\VAR{foo
}.
448 \IT{(
\SO*
{SYMBOL-MACROLET
} (
\OPn{(
\VAR{foo
}
449 \VAR{expansion-form
})
})
\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
452 Evaluate
\retval{\VAR{form
}s
} with locally defined symbol macros
456 \IT{(
\MC*
{DEFSETF
} \NEV{\VAR{function
}} \xorGOO{% %FIXME:BLOCK
457 \NEV{\VAR{updater
}} \text{ } \Op{\NEV{\VAR{doc
}}}\\
458 (
\OPn{\VAR{setf-$
\lambda$
}})
\text{ } (
\OPn{\VAR{s-var
}})
\text{ }
459 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\text{ }
460 \Op{\NEV{\VAR{doc
}}} \text{ } \OPn{form
}}{\
}})
462 where defsetf lambda list (
\OPn{\VAR{setf-$
\lambda$
}}) has the form
465 \OP{\kwd*
{\&optional
} \xorGOO{%
467 (
\VAR{var
} \OP{\VAR{init
}\DF{\NIL}\text{ } \Op{\VAR{supplied-p
}}})
}{\
}}}
469 \Op{\kwd*
{\&rest
} \VAR{var
}}
471 \OP{\kwd*
{\&key
} \xorGOO{%
475 (
\kwd{:
}\VAR{key
} \VAR{var
})
}{\
}}
476 \text{ }\OP{\VAR{init
}\DF{\NIL}\text{ }\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
478 \Op{\kwd*
{\&allow-other-keys
}}}
480 \OP{\kwd*
{\&environment
} \VAR{var
}}%
484 Specify how to
\kwd{setf
} a place accessed by
485 \retval{\VAR{function
}}.
486 Short form: (
\kwd{setf
} (
\VAR{function
} \OPn{\VAR{arg
}})
\VAR{value-form
}) is
487 replaced by (
\VAR{updater
} \OPn{\VAR{arg
}} \VAR{value-form
}).
488 Long form: on invocation of (
\kwd{setf
} (
\VAR{function
}
489 \OPn{\VAR{arg
}})
\VAR{value-form
}),
\OPn{\VAR{form
}} must expand
490 into code setting the place accessed where
\VAR{setf-$
\lambda$
}
491 and
\OPn{\VAR{s-var
}} describe the arguments of
\VAR{function
} and
492 the value(s) to be stored, respectively.
\VAR{form
}s must provide for returning
493 the value(s) of
\OPn{\VAR{s-var
}}.
496 \IT{(
\MC*
{DEFINE-SETF-EXPANDER
} \VAR{function
}
497 (
\OPn{\VAR{macro-$
\lambda$
}})
%FIXME:BLOCK
498 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
} \Op{\NEV{\VAR{doc
}}}
501 Specify how to
\kwd{setf
} a place accessed by
502 \retval{\VAR{function
}}. On invocation of (
\kwd{setf
} (
\VAR{function
}
503 \OPn{\VAR{arg
}})
\VAR{value-form
}),
\OPn{\VAR{form
}} must expand
504 into code returning
\VAR{arg-vars
},
\VAR{args
},
\VAR{newval-vars
},
505 \VAR{set-form
}, and
\VAR{get-form
} as described with
506 \FU{GET-SETF-EXPANSION
}. In the expansion, the elements of macro
507 lambda list
\OPn{\VAR{macro-$
\lambda$
}} are bound to corresponding
511 \IT{(
\FU*
{GET-SETF-EXPANSION
} \VAR{place
} \Op{\VAR{environment
}})
}
513 Return lists of temporary variables
\retval{\VAR{arg-vars
}} and of
514 corresponding
\retvalii{\VAR{args
}} as given with
\VAR{place
},
515 list
\retvaliii{\VAR{\VAR{newval-vars
}}} with temporary variables
516 corresponding to the new values, and
\retvaln{4}{\VAR{set-form
}}
517 and
\retvaln{5}{get-form
} specifying in terms of
\VAR{arg-vars
}
518 and
\VAR{newval-vars
} how to
\kwd{setf
} and how to read
522 \IT{(
\MC*
{DEFINE-MODIFY-MACRO
} \VAR{foo
}
523 (
\OP{\kwd*
{\&optional
} \xorGOO{%
525 (
\VAR{var
} \OP{\VAR{init
}\DF{\NIL}\text{ }
526 \Op{\VAR{supplied-p
}}})
}{\
}}}
527 \Op{\kwd*
{\&rest
} \VAR{var
}})
528 \VAR{function
} \Op{\NEV{\VAR{doc
}}})
}
530 Define macro
\retval{\VAR{foo
}} able to modify a place. On
531 invocation of (
\VAR{foo
} \VAR{place
} \OPn{\VAR{arg
}}), the value of
532 \VAR{function
} applied to
\VAR{place
} and
\VAR{arg
}s will be stored into
533 \VAR{place
} and returned.
536 \IT{\CNS*
{LAMBDA-LIST-KEYWORDS
}}
537 {List of macro lambda list keywords.
543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
544 \subsection{Control Flow
}
545 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
548 \IT{(
\SO*
{IF
} \VAR{test
} \VAR{then
} \Op{\VAR{else
}\DF{\NIL}})
}
550 \retval{\VAR{then
}} if
\VAR{test
} returns
\T; return value of
551 \retval{\VAR{else
}} otherwise.
554 \IT{(
\MC*
{COND
} \OPn{(
\VAR{test
} \PROGN{\VAR{then
}}\DF{\VAR{test
}})
})
}
556 Return the
\retval{values
} of the first
557 \OPn{\VAR{then
}} whose
\VAR{test
} returns
\T; return
558 \retval{\NIL} if all
\VAR{test
}s returns
\NIL.
561 \IT{(
\xorGOO{\MC*
{WHEN
}\\
562 \MC*
{UNLESS
}}{\
}} \VAR{test
}
563 \PROGN{\VAR{foo
}}\DF{\NIL})
}
565 Evaluate
\VAR{foo
}s and return
\retval{their values
} if
\VAR{test
}
566 returns
\T\ or
\NIL, respectively. Return
\retval{\NIL} otherwise.
569 \IT{(
\MC*
{CASE
} \VAR{test
} \OPn{(
\NEV{\VAR{keys
}} \PROGN{\VAR{foo
}})
}
570 \Op{(
\Goo{\T\XOR\kwd*
{OTHERWISE
}} \PROGN{\VAR{bar
}})
\DF{\NIL}})
}
572 Return the
\retval{values
} of the first
\OPn{\VAR{foo
}} one of whose
\VAR{keys
} is
573 \kwd{eql
} \VAR{test
}.
574 Return
\retval{values of
\VAR{bar
}s
} if no element of
\VAR{keys
} matches.
577 \IT{(
\Goo{\MC*
{CCASE
}\XOR\MC*
{ECASE
}} \VAR{test
}
578 \OPn{(
\NEV{\VAR{keys
}} \PROGN{\VAR{foo
}})
})
}
580 Return the
\retval{values
} of the first
\OPn{\VAR{foo
}} one of whose
\VAR{keys
} is
\kwd{eql
}
581 \VAR{test
}. Return
\retval{\NIL} and signal correctable
582 error/non-correctable
\kwd{type-error
}, respectively, if no element of
586 \IT{(
\MC*
{AND
} \OPn{\VAR{form
}}\DF{\T})
}
588 Evaluate
\VAR{form
}s from left to
589 right. Immediately return
\retval{\NIL} if one
\VAR{form
}'s value is
\NIL. Return
590 \retval{values of last
\VAR{form
}} otherwise.
593 \IT{(
\MC*
{OR
} \OPn{\VAR{form
}}\DF{\NIL})
}
595 Evaluate
\VAR{form
}s from left to
596 right. Immediately return
\retval{primary value
} of first
597 non-
\NIL-evaluating form, or
\retval{all values
} if last
\VAR{form
}
598 is reached. Return
\retval{\NIL} if no
\VAR{form
} returns
\T.
601 \IT{(
\SO*
{PROGN
} \OPn{\VAR{form
}}\DF{\NIL})
}
603 Evaluate
\VAR{form
}s sequentially. Return
604 \retval{values of last
\VAR{form
}}.
607 \IT{(
\xorGOO{\MC*
{PROG
}\\%FIXME:BLOCK
611 (
\VAR{var
} \Op{ \VAR{value
}})
}{\
}^
{\!\!*
}})
612 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
613 \xorGOO{\NEV{\VAR{tag
}}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
615 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
}s locally bound (in parallel or sequentially, respectively) to
616 \VAR{value
}s. Return
\retval{\NIL} or explicitly
617 \retval{\MC{return
}ed value
}.
621 (
\SO*
{MULTIPLE-VALUE-PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
622 (
\MC*
{PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
623 (
\MC*
{PROG2
} \VAR{ form-a
} \VAR{ form-r
} \OPn{\VAR{ form
}})
}{.
}}
625 Evaluate forms in order. Return
\retval{values/
1st value
},
626 respectively, of
\VAR{form-r
}.
629 \IT{(
\SO*
{PROGV
} \VAR{symbols
} \VAR{values
} \PROGN{\VAR{form
}})
}
631 Evaluate
\VAR{form
}s with
\VAR{symbols
} dynamically bound to
\VAR{values
} or
632 \NIL. Return
\retval{values of
\VAR{form
}s
}.
635 \IT{(
\SO*
{UNWIND-PROTECT
} \VAR{protected
} \OPn{\VAR{cleanup
}})
}
637 Evaluate
\VAR{protected
} and then, no matter how control leaves
638 \VAR{protected
},
\VAR{cleanup
}s. Return
\retval{values of
642 \IT{(
\MC*
{DESTRUCTURING-BIND
} \VAR{foo
} \VAR{bar
} \OPn{(
\kwd{declare
}
643 \OPn{\NEV{\VAR{decl
}}})
} \PROGN{\VAR{form
}})
}
645 Evaluate
\VAR{form
}s and return
\retval{their values
},
646 with variables from tree
\VAR{foo
} bound to corresponding elements
650 \IT{(
\MC*
{MULTIPLE-VALUE-BIND
} (
\OPn{\NEV{\VAR{var
}}})
\VAR{values-form
}
651 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
} \PROGN{\VAR{body-form
}})
}
654 \VAR{body-form
}s with
\VAR{var
}s bound to the return values of
655 \VAR{values-form
}. Return
\retval{values of
\VAR{body-form
}s
}.
658 \IT{(
\xorGOO{\SO*
{LET
}\\
661 (
\VAR{name
}\Op{\VAR{value
}\DF{\NIL}})
}{\
}^
{\!\!*
}})
662 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
665 Evaluate
\VAR{form
}s with
\VAR{name
}s bound (in parallel or
666 sequentially, respectively) to
\VAR{value
}s. Return
667 \retval{values of
\VAR{form
}s
}.
670 \IT{(
\SO*
{LOCALLY
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
673 Evaluate
\VAR{form
}s with declarations
\VAR{decl
} in
674 effect. Return
\retval{values of
\VAR{form
}s
}.
677 \IT{\arrGOO{(
\SO*
{RETURN-FROM
} \VAR{foo
} \Op{\VAR{result
}\DF{\NIL}})\\
678 (
\MC*
{RETURN
} \Op{\VAR{result
}\DF{\NIL}})
}{.
}}
680 Have nearest enclosing
\SO{block
} named
\VAR{foo
}/named
\NIL,
681 repectively, return with values of
\VAR{result
}.
684 \IT{(
\SO*
{BLOCK
} \VAR{name
} \PROGN{\VAR{form
}})
}
686 Evaluate
\VAR{form
}s and return
\retval{their values
} unless
687 interrupted by
\SO{RETURN-FROM
}.
690 \IT{(
\SO*
{TAGBODY
} \Goos{\NEV{\VAR{tag
}}\XOR\VAR{form
}})
}
692 Evaluate
\VAR{form
}s.
\VAR{tag
}s (symbols or integers) are targets
693 for
\SO{GO
}. Return
\retval{\NIL}.
696 \IT{(
\SO*
{GO
} \VAR{tag
})
}
697 {Jump within a
\SO{tagbody
} to nearest
698 lexically enclosing
\kwd{eql
} \VAR{tag
}.
701 \IT{(
\SO*
{CATCH
} \VAR{tag
} \PROGN{\VAR{form
}})
}
703 Evaluate
\VAR{form
}s and return
\retval{their values
} unless
704 interrupted by
\SO{THROW
}.
707 \IT{(
\SO*
{THROW
} \VAR{tag
} \VAR{form
})
}
708 {Have the nearest dynamically
709 enclosing
\SO{CATCH
} with a tag
\FU{eq
} \VAR{tag
} return with the
710 values of
\VAR{form
}.
713 \IT{(
\FU*
{SLEEP
} \VAR{n
})
}
714 {Wait
\VAR{n
} seconds, return
\retval{\NIL}.
720 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
721 \subsection{Iteration
}
722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
726 \IT{(
\xorGOO{\MC*
{DO
}\\%FIXME:BLOCK
730 (
\VAR{var
} \OP{ \VAR{start
} \Op{\VAR{step
}}})
}{\
}^
{\!\!*
}})
731 (
\VAR{stop
} \PROGN{\VAR{result
}})
732 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
733 \xorGOO{\NEV{\VAR{tag
}}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
735 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
}s successively bound according
736 to the values of the corresponding
\VAR{start
} and
\VAR{step
}
737 forms.
\VAR{var
}s are bound in parallel/sequentially, respectively.
738 Stop iteration when
\VAR{stop
} is
\T. Return
\retval{values of
742 \IT{(
\MC*
{DOTIMES
} (
\VAR{var
} \VAR{integer
} \Op{\VAR{result
}})
%FIXME:BLOCK
743 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
744 \Goos{\NEV{\VAR{tag
}}\XOR\VAR{form
}})
}
746 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
} successively bound
747 to integers from
0 to $
\mbox{\VAR{integer
}} -
1$. Upon evaluation of
748 \retval{\VAR{result
}},
\VAR{var
} is
\NIL.
751 \IT{(
\MC*
{DOLIST
}(
\VAR{var
} \VAR{list
} \Op{\VAR{result
}})
752 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
753 \Goos{\NEV{\VAR{tag
}}\XOR\VAR{form
}})
}
755 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
} successively bound
756 to the elements of
\VAR{list
}. Upon evaluation of
757 \retval{\VAR{result
}},
\VAR{var
} is
\NIL.
763 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
764 \subsection{Loop Facility
}
765 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
773 \text{\kwd{loop
}}\text{ }
775 \text{\LKWD{named
} \VAR{n
}}
779 \text{\LKWD{with
} \VAR{var
} \Op{\VAR{type
}} \LKWD{=
} \VAR{foo
}}
780 \
{\text{\LKWD{and
} \VAR{var-n
} \Op{\VAR{type
}} \LKWD{=
}
781 \VAR{bar
}\
}}^
{*
} \\
[.1ex
]
788 \text{\VAR{var
} [\VAR{type
}]}
796 \text{\LKWD{upfrom
}}\\
800 \text{\VAR{start
}\DF{\LIT{0}}}
812 \text{\LKWD{from
} \VAR{start
}}
815 \text{\LKWD{downto
}}\\
820 \text{\LKWD{downfrom
} \VAR{start
}}\text{ }
824 \text{\LKWD{downto
}}\\
834 \text{\LKWD{by
} \VAR{step
}\DF{\LIT{1}}}
842 \text{\VAR{list
}}\text{ }
844 \text{\LKWD{by
} \VAR{function
}\DF{\kwd{cdr
}}}
846 \text{\LKWD{=
} \VAR{foo
}}
848 \text{\LKWD{then
} \VAR{bar
}}
850 \text{\LKWD{across
} \VAR{vector
}}\\
864 \text{\LKWD{hash-key
}}\\
865 \text{\LKWD{hash-keys
}}
876 \text{\LKWD{using
} (
\LKWD{hash-value
} \VAR{v
})
}
880 \text{\LKWD{hash-value
}}\\
881 \text{\LKWD{hash-values
}}
892 \text{\LKWD{using
} (
\LKWD{hash-key
} \VAR{k
})
}
898 \text{\LKWD{symbol
\Op{s
}}}\\
899 \text{\LKWD{present-symbol
\Op{s
}}}\\
900 \text{\LKWD{external-symbol
\Op{s
}}}
909 \right\
} \text{\VAR{package
}\DF{\V{\A package
\A}}}
914 \right\
}_
{\displaystyle{\mathbb{F
}_0
}}
917 \text{\LKWD{and
} }\boxed{\mathbb{F
}_i\!
}
922 \text{\LKWD{initially
}} \\
923 \text{\LKWD{finally
}}
926 \text{\VAR{form
}}^
{+
} \\
929 \right\
}^
{\!\!
\displaystyle{*
}}
933 \text{\LKWD{repeat
} \VAR{num
}}\\
936 \text{\LKWD{while
}}\\
937 \text{\LKWD{until
}}\\
938 \text{\LKWD{always
}}\\
939 \text{\LKWD{never
}}\\
940 \text{\LKWD{thereis
}}
953 \text{\VAR{form
}}^
{+
}\\
963 \text{\LKWD{collect
\Op{ing
}}}\\
964 \text{\LKWD{append
\Op{ing
}}}\\
965 \text{\LKWD{nconc
\Op{ing
}}}
973 \right\
} \Op{\text{\LKWD{into
}\VAR{var
}}}\\
976 \text{\LKWD{count
\Op{ing
}}}\\
977 \text{\LKWD{sum
\Op{ming
}}}\\
978 \text{\LKWD{maximize
}}\\
979 \text{\LKWD{maximizing
}}\\
980 \text{\LKWD{minimize
}}\\
981 \text{\LKWD{minimizing
}}
990 \Op{\text{\LKWD{into
}\VAR{num
}}}\text{ }
991 \Op{\text{\VAR{type
}}}\\
1000 \boxed{\mathbb{C
}_i\!
}\
{\text{\LKWD{and
}}
1001 \boxed{\mathbb{C
}_j\!
}\
}^
{*
}\Op{\text{\LKWD{else
}}
1002 \boxed{\mathbb{C
}_k\!
}\
{\text{\LKWD{and
}}
1003 \boxed{\mathbb{C
}_l\!
}\
}^
{*
}}
1004 \Op{\text{\LKWD{end
}}}
1006 \right._
{\!\!\!\!
\displaystyle{\mathbb{C
}_0
}}
1012 \text{\LKWD{initially
}} \\
1013 \text{\LKWD{finally
}}
1016 \text{\VAR{form
}}^
{+
}
1018 \right\
}^
{\displaystyle{\!\!*
}}
1022 \end{center
}\vspace{-
1em
}
1023 \caption{Loop Facility, Overview.
\label{loop-overview
}}%
1029 \IT{(
\MC*
{LOOP
} \OPn{\VAR{form
}})
} %FIXME:BLOCK
1031 Simple Loop. If
\VAR{form
}s do not contain any Loop Facility
1032 keywords, evaluate them forever.
1035 \IT{(
\MC*
{LOOP
} \OPn{\VAR{form
}})
} %FIXME:BLOCK;TAGBODY
1037 Loop Facility. For Loop Facility keywords
1038 see below and Figure
\ref{loop-overview
}.
1043 \IT{\LKWD*
{named
} \VAR{n
}}
1045 Give implicit
\kwd{block
} of loop a name.
1048 \IT{\LKWD*
{with
} \VAR{var
} \Op{\VAR{type
}} \LKWD*
{=
} \VAR{foo
} \Goos{\LKWD*
{and
}
1049 \VAR{var-n
} \Op{\VAR{type
}} \LKWD*
{=
} \VAR{bar
}}}
1051 Initialize local variables in parallel.
1054 \IT{\Goo{\LKWD*
{initially
}\XOR\LKWD*
{finally
}} \RP{\VAR{form
}}}
1056 Evaluate
\VAR{form
}s before begin, or after end, respectively, of iterations.
1059 \IT{\Goo{\LKWD*
{for
}\XOR\LKWD*
{as
}\XOR\LKWD*
{and
}} \VAR{var
} \Op{\VAR{type
}}}
1061 Begin of iteration control clauses;
\VAR{var
}s are initialized and
1062 stepped in parallel.
1067 \IT{\Goo{\LKWD*
{upfrom
}\XOR\LKWD*
{from
}\XOR\LKWD*
{downfrom
}}
1070 Start stepping with
\VAR{start
}
1073 \IT{\Goo{\LKWD*
{upto
}\XOR\LKWD*
{downto
}\XOR\LKWD*
{to
}\XOR\LKWD*
{below
}\XOR\LKWD*
{above
}}
1076 Specify
\VAR{form
} as the end value for stepping.
1079 \IT{\Goo{\LKWD*
{in
}\XOR\LKWD*
{on
}} \VAR{list
}}
1081 Bind
\VAR{var
} to successive elements/tails, respectively, of
\VAR{list
}.
1084 \IT{\LKWD*
{by
} \Goo{\VAR{step
}\DF{\LIT{1}}\XOR\VAR{function
}\DF{\FU{cdr
}}}}
1086 Specify the (positive) decrement or increment or the
1087 \VAR{function
} of one argument returning the next part of the list.
1090 \IT{\LKWD*
{=
} \VAR{foo
} \Op{\LKWD*
{then
}
1091 \VAR{bar
}\DF{\VAR{foo
}}}}
1093 Bind
\VAR{var
} in the first iteration to
\VAR{foo
} and later to
\VAR{bar
}.
1096 \IT{\LKWD*
{across
} \VAR{vector
}}
1098 Bind
\VAR{var
} to successive elements of
\VAR{vector
}.
1101 \IT{\LKWD*
{being
} \Goo{\LKWD*
{the
}\XOR\LKWD*
{each
}}}
1103 Iterate over a hash table or a package.
1108 \IT{\Goo{\LKWD*
{hash-key
}\XOR\LKWD*
{hash-keys
}} \Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
1109 \Op{\LKWD*
{using
} (
\LKWD*
{hash-value
} \VAR{value
})
}}
1111 Bind
\VAR{var
} successively to the keys of
\VAR{hash-table
}; bind
\VAR{value
} to corresponding values.
1114 \IT{\Goo{\LKWD*
{hash-value
}\XOR\LKWD*
{hash-values
}} \Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
1115 \Op{\LKWD*
{using
} (
\LKWD*
{hash-key
} \VAR{key
})
}}
1117 Bind
\VAR{var
} successively to the values of
\VAR{hash-table
}; bind
\VAR{key
} to corresponding keys.
1120 \IT{\Goo{\LKWD*
{symbol
}\XOR\LKWD*
{symbols
}\XOR\LKWD*
{present-symbol
}\XOR\LKWD*
{present-symbols
}\XOR\LKWD*
{external-symbol
}\XOR\LKWD*
{external-symbols
}}
1121 \Op{\Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}}
1122 \VAR{package
}\DF{\V{\A package
\A}}}}
1124 Bind
\VAR{var
} successively to the symbols, or the present
1125 symbols, or the external symbols respectively, of
1132 \IT{\Goo{\LKWD*
{do
}\XOR\LKWD*
{doing
}} \RP{\VAR{form
}}}
1134 Evaluate
\VAR{form
}s in every iteration.
1139 Value of
\VAR{test
} form of an enclosing
\LKWD{if
},
1140 \LKWD{when
},
\LKWD{unless
}, or
\LKWD{else
} clause.
1143 \IT{\LKWD*
{return
} \Goo{\VAR{form
}\XOR\LKWD*
{it
}}}
1145 Return immediately, skipping any
\LKWD{finally
} parts, with value of
\VAR{form
} or
\LKWD{it
}.
1148 \IT{\Goo{\LKWD*
{collect
}\XOR\LKWD*
{collecting
}}
1149 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
} \VAR{list
}}}
1151 Collect values of
\VAR{form
} or
\LKWD{it
} into
\VAR{list
}. If no
1152 \VAR{list
} is given, collect into an anonymous list which is
1153 returned after termination.
1156 \IT{\Goo{\LKWD*
{append
}\XOR\LKWD*
{appending
}\XOR\LKWD*
{nconc
}\XOR\LKWD*
{nconcing
}}
1157 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1160 Concatenate values of
\VAR{form
} or
\LKWD{it
}, which should be
1161 lists, into
\VAR{list
} by the means of
\FU{append
} or
\FU{nconc
},
1162 respectively. If no
\VAR{list
} is given, collect into an
1163 anonymous list which is returned after termination.
1166 \IT{\Goo{\LKWD*
{count
}\XOR\LKWD*
{counting
}}
1167 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1168 \VAR{n
}} \Op{\VAR{type
}}}
1170 Count the number of times the value of
\VAR{form
} or of
\LKWD{it
} is
\T.
1171 If no
\VAR{n
} is given, count into an anonymous variable
1172 which is returned after termination.
1175 \IT{\Goo{\LKWD*
{sum
}\XOR\LKWD*
{summing
}}
1176 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1177 \VAR{sum
}} \Op{\VAR{type
}}}
1179 Calculate the sum of the values of
\VAR{form
} or of
\LKWD{it
}.
1180 If no
\VAR{sum
} is given, sum into an anonymous variable
1181 which is returned after termination.
1184 \IT{\Goo{\LKWD*
{maximize
}\XOR\LKWD*
{maximizing
}\XOR
1185 \LKWD*
{minimize
}\XOR
1186 \LKWD*
{minimizing
}} \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1187 \VAR{max-min
}} \Op{\VAR{type
}}}
1189 Determine the maximum or minimum, respectively, of the values of
1190 \VAR{form
} or of
\LKWD{it
}.
1191 If no
\VAR{max-min
} is given, use an anonymous variable
1192 which is returned after termination.
1195 \IT{\Goo{\LKWD*
{if
}\XOR\LKWD*
{when
}\XOR\LKWD*
{unless
}} \VAR{ test
}
1196 \VAR{i-form
} \Goos{\LKWD*
{and
}
1197 \VAR{j-form
}} \Op{\LKWD*
{else
} \VAR{k-form
} \Goos{\LKWD*
{and
}
1198 \VAR{l-form
}}} \Op{\LKWD*
{end
}}}
1200 If
\VAR{test
} returns
\T,
\T, or
\NIL, respectively, evaluate
1201 \VAR{i-form
} and
\VAR{j-form
}s; otherwise, evaluate
\VAR{k-form
}
1202 and
\VAR{l-form
}s. Inside
\VAR{i-form
} and
\VAR{k-form
}, the value
1203 of
\VAR{test
} is accessible by
\LKWD*
{it
}.
1206 \IT{\LKWD*
{repeat
} \VAR{num
}}
1208 Terminate
\MC{loop
} after
\VAR{num
} times;
\VAR{num
} is evaluated once.
1211 \IT{\Goo{\LKWD*
{while
}\XOR\LKWD*
{until
}} \VAR{test
}}
1213 Continue iteration until
\VAR{test
} returns
\NIL\ or
\T, respectively.
1216 \IT{\Goo{\LKWD*
{always
}\XOR\LKWD{never
}} \VAR{test
}}
1218 Terminate
\MC{loop
} returning
\NIL\ and skipping any
1219 \LKWD*
{finally
} parts as soon as
\VAR{test
} is
\NIL\ or
\T,
1220 respectively. Otherwise continue
\MC{loop
} with its default return
1224 \IT{\LKWD*
{thereis
} \VAR{test
}}
1226 Terminate
\MC{loop
} when
\VAR{test
} is
\T\ and return value of
1227 \VAR{test
}, skipping any
\LKWD*
{finally
} parts. Otherwise continue
1228 \MC{loop
} with its default return value set to
\NIL.
1231 \IT{\LKWD*
{loop-finish
}}
1233 Terminate
\MC{loop
} immediately returning any accumulated results.