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
}\DF{\NIL}})
}
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
}\\
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. For
\MC{defun
},
\VAR{form
}s are
220 enclosed in an implicit
\SO{block
} \VAR{foo
}.
223 \IT{(
\xorGOO{\SO*
{FLET
}\\
226 (
\OPn{\VAR{ord-$
\lambda$
}})
227 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{local-decl
}}})
}
229 \PROGN{\VAR{local-form
}})
})
\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
232 Evaluate
\VAR{form
}s with
233 locally defined functions
\VAR{foo
}. Each
\VAR{foo
} is also the name
234 of an implicit
\SO{block
} around its corresponding
235 \OPn{\VAR{local-form
}}. Only for
\SO{LABELS
}, functions
\VAR{foo
} are visible inside
\VAR{local-forms
}. Return
236 \retval{values of
\VAR{form
}s
}.
239 \IT{(
\SO*
{FUNCTION
} \xorGOO{%
241 (
\MC{lambda
} \OPn{\VAR{form
}})
}{\
}})
}
243 Return lexically innermost
\retval{function
} named
\VAR{foo
} or a
244 lexical closure of the
\retval{\MC{lambda
} expression
}.
247 \IT{(
\FU*
{APPLY
} \VAR{function
} \RP{\VAR{arg
}})
}
249 Return
\retval{values of
\VAR{function
}} called on
250 \VAR{arg
}s. Last
\VAR{arg
} must be a list.
\kwd{setf
}able if
251 \VAR{function
} is one of
\FU{aref
},
\FU{bit
}, and
\FU{sbit
}.
254 \IT{(
\FU*
{FUNCALL
} \VAR{function
} \OPn{arg
})
}
256 Return
\retval{values of
\VAR{function
}} called with
\VAR{arg
}s.
259 \IT{(
\SO*
{MULTIPLE-VALUE-CALL
} \VAR{foo
} \OPn{\VAR{form
}})
}
261 \VAR{foo
} with all the values of each
\VAR{form
} as its arguments. Return
262 \retval{values returned by
\VAR{foo
}}.
265 \IT{(
\FU*
{VALUES-LIST
} \VAR{list
})
}
267 Return
\retval{elements of
\VAR{list
}}.
270 \IT{(
\FU*
{VALUES
} \OPn{\VAR{foo
}})
}
272 Return as multiple values the
\retval{primary values
} of the
273 \VAR{foo
}s.
\kwd{setf
}able.
276 \IT{(
\FU*
{MULTIPLE-VALUE-LIST
} \VAR{form
})
}
278 Return in a
\retval{list
} values of
\VAR{form
}.
281 \IT{(
\FU*
{NTH-VALUE
} \VAR{n
} \VAR{form
})
}
283 Zero-indexed
\retval{\VAR{n
}th return value
} of
\VAR{form
}.
286 \IT{(
\FU*
{COMPLEMENT
} \VAR{function
})
}
288 Return
\retval{new function
} with same arguments and same side effects
289 as
\VAR{function
}, but with complementary truth value.
292 \IT{(
\FU*
{CONSTANTLY
} \VAR{foo
})
}
294 Return
\retval{function
} of any number of arguments returning
\VAR{foo
}.
297 \IT{(
\FU*
{IDENTITY
} \VAR{foo
})
}
299 Return
\retval{\VAR{foo
}}.
302 \IT{(
\FU*
{FUNCTION-LAMBDA-EXPRESSION
} \VAR{function
})
}
304 If available, return
\retval{lambda expression
} of
\VAR{function
},
305 \retvalii{\NIL} if
\VAR{function
} was defined in an environment
306 without bindings, and
\retvaliii{name
} of
\VAR{function
}.
309 \IT{(
\FU*
{FDEFINITION
} \VAR{foo
})
}
311 \retval{Definition
} of global function
\VAR{foo
}.
\kwd{setf
}able.
314 \IT{(
\FU*
{FMAKUNBOUND
} \VAR{foo
})
}
316 Remove global function or macro definition
\retval{\VAR{foo
}}.
319 \IT{\arrGOO{\CNS*
{CALL-ARGUMENTS-LIMIT
}\\
320 \CNS*
{LAMBDA-PARAMETERS-LIMIT
}}{.
}}
322 Upper bound of the number of function arguments or lambda list
323 parameters, respectively; $
\geq50$.
326 \IT{\CNS*
{MULTIPLE-VALUES-LIMIT
}}
328 Upper bound of the number of values a function can return; $
\geq20$.
334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
336 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
337 \label{section:Macros
}
340 Below, macro lambda list (
\OPn{\VAR{macro-$
\lambda$
}}) has the form of
343 (
\Op{\kwd*
{\&whole
} \VAR{var
}}
349 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}^
{\!\!*
}}
353 \Op{\kwd*
{\&optional
}
358 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}\text{ }
359 \OP{\VAR{init
}\DF{\NIL}\text{ } \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
369 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}}
378 (
\kwd{:
}\VAR{key
} \xorGOO{%
380 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}})
}{\
}}
381 \text{ }\OP{\VAR{init
}\DF{\NIL}\text{ } \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
383 \Op{\kwd*
{\&allow-other-keys
}}}
388 (
\VAR{var
} \Op{\VAR{init
}\DF{\NIL}})
}{\
}^
{\!\!*
}}}
401 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}^
{\!\!*
}}
405 \Op{\kwd*
{\&optional
}
410 (
\OPn{\VAR{macro-$
\lambda$
}})
}{\
}}\text{ }
411 \OP{\VAR{init
}\DF{\NIL}\text{ } \Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}}
417 One toplevel
\Op{\VAR{E
}} may be replaced by
\kwd*
{\&environment
}
418 \VAR{var
}.
\VAR{supplied-p
} is
\T\ if there is a corresponding
424 \IT{(
\xorGOO{\MC*
{DEFMACRO
}\\
425 \FU*
{DEFINE-COMPILER-MACRO
}}{\
}}
426 \VAR{foo
} (
\OPn{\VAR{macro-$
\lambda$
}})
427 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
} \Op{\NEV{\VAR{doc
}}}
430 Define macro
\retval{\VAR{foo
}} which on evaluation as (
\VAR{foo
}
431 \VAR{tree
}) applies expanded
\VAR{form
}s to arguments from
432 \VAR{tree
} which corresponds to
\VAR{tree
}-shaped
433 \VAR{macro-$
\lambda$
}s.
\VAR{form
}s are enclosed in an implicit
434 \SO{block
} \VAR{foo
}.
437 \IT{(
\MC*
{DEFINE-SYMBOL-MACRO
} \VAR{foo
} \VAR{form
})
}
439 Define symbol macro
\retval{\VAR{foo
}} which on evaluation evaluates
443 \IT{(
\SO*
{MACROLET
} (
\OPn{(
\VAR{foo
} (
\OPn{\VAR{macro-$
\lambda$
}})
444 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{local-decl
}}})
}
445 \Op{\NEV{\VAR{doc
}}} \PROGN{\VAR{macro-form
}})
})
\OPn{(
\kwd{declare
}
446 \OPn{\NEV{\VAR{decl
}}})
} \PROGN{\VAR{form
}})
}
448 Evaluate
\retval{\VAR{form
}s
} with locally defined mutually
449 invisible macros
\VAR{foo
} which are enclosed in implicit
\SO{block
}s
453 \IT{(
\SO*
{SYMBOL-MACROLET
} (
\OPn{(
\VAR{foo
}
454 \VAR{expansion-form
})
})
\OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
457 Evaluate
\retval{\VAR{form
}s
} with locally defined symbol macros
461 \IT{(
\MC*
{DEFSETF
} \NEV{\VAR{function
}} \xorGOO{%
462 \NEV{\VAR{updater
}} \text{ } \Op{\NEV{\VAR{doc
}}}\\
463 (
\OPn{\VAR{setf-$
\lambda$
}})
\text{ } (
\OPn{\VAR{s-var
}})
\text{ }
464 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}\text{ }
465 \Op{\NEV{\VAR{doc
}}} \text{ } \PROGN{\VAR{form
}}}{\
}})
467 where defsetf lambda list (
\OPn{\VAR{setf-$
\lambda$
}}) has the form
470 \OP{\kwd*
{\&optional
} \xorGOO{%
472 (
\VAR{var
} \OP{\VAR{init
}\DF{\NIL}\text{ } \Op{\VAR{supplied-p
}}})
}{\
}}}
474 \Op{\kwd*
{\&rest
} \VAR{var
}}
476 \OP{\kwd*
{\&key
} \xorGOO{%
480 (
\kwd{:
}\VAR{key
} \VAR{var
})
}{\
}}
481 \text{ }\OP{\VAR{init
}\DF{\NIL}\text{ }\Op{\VAR{supplied-p
}}})
}{\
}^
{\!\!*
}}
483 \Op{\kwd*
{\&allow-other-keys
}}}
485 \OP{\kwd*
{\&environment
} \VAR{var
}}%
489 Specify how to
\kwd{setf
} a place accessed by
490 \retval{\VAR{function
}}.
491 Short form: (
\kwd{setf
} (
\VAR{function
} \OPn{\VAR{arg
}})
\VAR{value-form
}) is
492 replaced by (
\VAR{updater
} \OPn{\VAR{arg
}} \VAR{value-form
}).
493 Long form: on invocation of (
\kwd{setf
} (
\VAR{function
}
494 \OPn{\VAR{arg
}})
\VAR{value-form
}),
\VAR{form
}s must expand
495 into code that sets the place accessed where
\VAR{setf-$
\lambda$
}
496 and
\OPn{\VAR{s-var
}} describe the arguments of
\VAR{function
} and
497 the value(s) to be stored, respectively; and that returns
498 the value(s) of
\OPn{\VAR{s-var
}}.
\VAR{form
}s are enclosed in an
499 implicit
\SO{block
} \VAR{foo
}.
502 \IT{(
\MC*
{DEFINE-SETF-EXPANDER
} \VAR{function
}
503 (
\OPn{\VAR{macro-$
\lambda$
}})
504 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
} \Op{\NEV{\VAR{doc
}}}
507 Specify how to
\kwd{setf
} a place accessed by
508 \retval{\VAR{function
}}. On invocation of (
\kwd{setf
} (
\VAR{function
}
509 \OPn{\VAR{arg
}})
\VAR{value-form
}),
\OPn{\VAR{form
}} must expand
510 into code returning
\VAR{arg-vars
},
\VAR{args
},
\VAR{newval-vars
},
511 \VAR{set-form
}, and
\VAR{get-form
} as described with
512 \FU{GET-SETF-EXPANSION
} where the elements of macro
513 lambda list
\OPn{\VAR{macro-$
\lambda$
}} are bound to corresponding
514 \VAR{arg
}s.
\VAR{form
}s are enclosed in an implicit
\SO{block
} \VAR{function
}.
517 \IT{(
\FU*
{GET-SETF-EXPANSION
} \VAR{place
} \Op{\VAR{environment
}})
}
519 Return lists of temporary variables
\retval{\VAR{arg-vars
}} and of
520 corresponding
\retvalii{\VAR{args
}} as given with
\VAR{place
},
521 list
\retvaliii{\VAR{\VAR{newval-vars
}}} with temporary variables
522 corresponding to the new values, and
\retvaln{4}{\VAR{set-form
}}
523 and
\retvaln{5}{get-form
} specifying in terms of
\VAR{arg-vars
}
524 and
\VAR{newval-vars
} how to
\kwd{setf
} and how to read
528 \IT{(
\MC*
{DEFINE-MODIFY-MACRO
} \VAR{foo
}
529 (
\OP{\kwd*
{\&optional
} \xorGOO{%
531 (
\VAR{var
} \OP{\VAR{init
}\DF{\NIL}\text{ }
532 \Op{\VAR{supplied-p
}}})
}{\
}}}
533 \Op{\kwd*
{\&rest
} \VAR{var
}})
534 \VAR{function
} \Op{\NEV{\VAR{doc
}}})
}
536 Define macro
\retval{\VAR{foo
}} able to modify a place. On
537 invocation of (
\VAR{foo
} \VAR{place
} \OPn{\VAR{arg
}}), the value of
538 \VAR{function
} applied to
\VAR{place
} and
\VAR{arg
}s will be stored into
539 \VAR{place
} and returned.
542 \IT{\CNS*
{LAMBDA-LIST-KEYWORDS
}}
543 {List of macro lambda list keywords.
549 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
550 \subsection{Control Flow
}
551 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
554 \IT{(
\SO*
{IF
} \VAR{test
} \VAR{then
} \Op{\VAR{else
}\DF{\NIL}})
}
556 \retval{\VAR{then
}} if
\VAR{test
} returns
\T; return value of
557 \retval{\VAR{else
}} otherwise.
560 \IT{(
\MC*
{COND
} \OPn{(
\VAR{test
} \PROGN{\VAR{then
}}\DF{\VAR{test
}})
})
}
562 Return the
\retval{values
} of the first
563 \OPn{\VAR{then
}} whose
\VAR{test
} returns
\T; return
564 \retval{\NIL} if all
\VAR{test
}s return
\NIL.
567 \IT{(
\xorGOO{\MC*
{WHEN
}\\
568 \MC*
{UNLESS
}}{\
}} \VAR{test
}
569 \PROGN{\VAR{foo
}}\DF{\NIL})
}
571 Evaluate
\VAR{foo
}s and return
\retval{their values
} if
\VAR{test
}
572 returns
\T\ or
\NIL, respectively. Return
\retval{\NIL} otherwise.
575 \IT{(
\MC*
{CASE
} \VAR{test
} \OPn{(
\NEV{\VAR{keys
}} \PROGN{\VAR{foo
}})
}
576 \Op{(
\Goo{\T\XOR\kwd*
{OTHERWISE
}} \PROGN{\VAR{bar
}})
\DF{\NIL}})
}
578 Return the
\retval{values
} of the first
\OPn{\VAR{foo
}} one of whose
\VAR{keys
} is
579 \kwd{eql
} \VAR{test
}.
580 Return
\retval{values of
\VAR{bar
}s
} if no element of
\VAR{keys
} matches.
583 \IT{(
\Goo{\MC*
{ECASE
}\XOR\MC*
{CCASE
}} \VAR{test
}
584 \OPn{(
\NEV{\VAR{keys
}} \PROGN{\VAR{foo
}})
})
}
586 Return the
\retval{values
} of the first
\OPn{\VAR{foo
}} one of whose
\VAR{keys
} is
\kwd{eql
}
587 \VAR{test
}. Signal non-correctable/correctable
\kwd{type-error
} and
588 return
\retval{\NIL} if no element of
\VAR{keys
} matches.
591 \IT{(
\MC*
{AND
} \OPn{\VAR{form
}}\DF{\T})
}
593 Evaluate
\VAR{form
}s from left to
594 right. Immediately return
\retval{\NIL} if one
\VAR{form
}'s value is
\NIL. Return
595 \retval{values of last
\VAR{form
}} otherwise.
598 \IT{(
\MC*
{OR
} \OPn{\VAR{form
}}\DF{\NIL})
}
600 Evaluate
\VAR{form
}s from left to
601 right. Immediately return
\retval{primary value
} of first
602 non-
\NIL-evaluating form, or
\retval{all values
} if last
\VAR{form
}
603 is reached. Return
\retval{\NIL} if no
\VAR{form
} returns
\T.
606 \IT{(
\SO*
{PROGN
} \OPn{\VAR{form
}}\DF{\NIL})
}
608 Evaluate
\VAR{form
}s sequentially. Return
609 \retval{values of last
\VAR{form
}}.
612 \IT{(
\xorGOO{\MC*
{PROG
}\\
616 (
\VAR{var
} \Op{ \VAR{value
}})
}{\
}^
{\!\!*
}})
617 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
618 \xorGOO{\NEV{\VAR{tag
}}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
620 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
}s locally bound (in
621 parallel or sequentially, respectively) to
\VAR{value
}s. Return
622 \retval{\NIL} or explicitly
\retval{\MC{return
}ed value
}.
623 Implicitly, the whole form is a
\SO{block
} named
\NIL.
627 (
\SO*
{MULTIPLE-VALUE-PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
628 (
\MC*
{PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
629 (
\MC*
{PROG2
} \VAR{ form-a
} \VAR{ form-r
} \OPn{\VAR{ form
}})
}{.
}}
631 Evaluate forms in order. Return
\retval{values/
1st value
},
632 respectively, of
\VAR{form-r
}.
635 \IT{(
\SO*
{PROGV
} \VAR{symbols
} \VAR{values
} \PROGN{\VAR{form
}})
}
637 Evaluate
\VAR{form
}s with
\VAR{symbols
} dynamically bound to
\VAR{values
} or
638 \NIL. Return
\retval{values of
\VAR{form
}s
}.
641 \IT{(
\SO*
{UNWIND-PROTECT
} \VAR{protected
} \OPn{\VAR{cleanup
}})
}
643 Evaluate
\VAR{protected
} and then, no matter how control leaves
644 \VAR{protected
},
\VAR{cleanup
}s. Return
\retval{values of
648 \IT{(
\MC*
{DESTRUCTURING-BIND
} \VAR{destruct-$
\lambda$
} \VAR{bar
} \OPn{(
\kwd{declare
}
649 \OPn{\NEV{\VAR{decl
}}})
} \PROGN{\VAR{form
}})
}
651 Evaluate
\VAR{form
}s with variables from tree
\VAR{destruct-$
\lambda$
} bound to
652 corresponding elements of tree
\VAR{bar
}, and return
\retval{their
653 values
}.
\VAR{destruct-$
\lambda$
} resembles
\VAR{macro-$
\lambda$
}
654 (section
\ref{section:Macros
}), but without any
\kwd{\&environment
}
658 \IT{(
\MC*
{MULTIPLE-VALUE-BIND
} (
\OPn{\NEV{\VAR{var
}}})
\VAR{values-form
}
659 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
} \PROGN{\VAR{body-form
}})
}
662 \VAR{body-form
}s with
\VAR{var
}s bound to the return values of
663 \VAR{values-form
}. Return
\retval{values of
\VAR{body-form
}s
}.
666 \IT{(
\xorGOO{\SO*
{LET
}\\
669 (
\VAR{name
}\Op{\VAR{value
}\DF{\NIL}})
}{\
}^
{\!\!*
}})
670 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
673 Evaluate
\VAR{form
}s with
\VAR{name
}s bound (in parallel or
674 sequentially, respectively) to
\VAR{value
}s. Return
675 \retval{values of
\VAR{form
}s
}.
678 \IT{(
\SO*
{LOCALLY
} \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
681 Evaluate
\VAR{form
}s with declarations
\VAR{decl
} in
682 effect. Return
\retval{values of
\VAR{form
}s
}.
685 \IT{(
\SO*
{BLOCK
} \VAR{name
} \PROGN{\VAR{form
}})
}
687 Evaluate
\VAR{form
}s with lexical scope and dynamic extent, and
688 return
\retval{their values
} unless interrupted by
692 \IT{\arrGOO{(
\SO*
{RETURN-FROM
} \VAR{foo
} \Op{\VAR{result
}\DF{\NIL}})\\
693 (
\MC*
{RETURN
} \Op{\VAR{result
}\DF{\NIL}})
}{.
}}
695 Have nearest enclosing
\SO{block
} named
\VAR{foo
}/named
\NIL,
696 repectively, return with values of
\VAR{result
}.
699 \IT{(
\SO*
{TAGBODY
} \Goos{\NEV{\VAR{tag
}}\XOR\VAR{form
}})
}
701 Evaluate
\VAR{form
}s.
\VAR{tag
}s (symbols or integers) are targets
702 for
\SO{GO
}. Return
\retval{\NIL}.
705 \IT{(
\SO*
{GO
} \VAR{tag
})
}
706 {Jump within a
\SO{tagbody
} to nearest
707 lexically enclosing
\kwd{eql
} \VAR{tag
}.
710 \IT{(
\SO*
{CATCH
} \VAR{tag
} \PROGN{\VAR{form
}})
}
712 Evaluate
\VAR{form
}s and return
\retval{their values
} unless
713 interrupted by
\SO{THROW
}.
716 \IT{(
\SO*
{THROW
} \VAR{tag
} \VAR{form
})
}
717 {Have the nearest dynamically
718 enclosing
\SO{CATCH
} with a tag
\FU{eq
} \VAR{tag
} return with the
719 values of
\VAR{form
}.
722 \IT{(
\FU*
{SLEEP
} \VAR{n
})
}
723 {Wait
\VAR{n
} seconds, return
\retval{\NIL}.
729 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
730 \subsection{Iteration
}
731 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
735 \IT{(
\xorGOO{\MC*
{DO
}\\
739 (
\VAR{var
} \OP{ \VAR{start
} \Op{\VAR{step
}}})
}{\
}^
{\!\!*
}})
740 (
\VAR{stop
} \PROGN{\VAR{result
}})
741 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
742 \xorGOO{\NEV{\VAR{tag
}}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
744 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
}s successively bound according
745 to the values of the corresponding
\VAR{start
} and
\VAR{step
}
746 forms.
\VAR{var
}s are bound in parallel/sequentially, respectively.
747 Stop iteration when
\VAR{stop
} is
\T. Return
\retval{values of
748 \OPn{\VAR{result
}}}. Implicitly, the whole form is a
\SO{block
}
752 \IT{(
\MC*
{DOTIMES
} (
\VAR{var
} \VAR{i
} \Op{\VAR{result
}})
753 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
754 \Goos{\NEV{\VAR{tag
}}\XOR\VAR{form
}})
}
756 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
} successively bound
757 to integers from
0 to $i -
1$. Upon evaluation of
758 \retval{\VAR{result
}},
\VAR{var
} is
\VAR{i
}. Implicitly, the whole
759 form is a
\SO{block
} named
\NIL.
762 \IT{(
\MC*
{DOLIST
}(
\VAR{var
} \VAR{list
} \Op{\VAR{result
}})
763 \OPn{(
\kwd{declare
} \OPn{\NEV{\VAR{decl
}}})
}
764 \Goos{\NEV{\VAR{tag
}}\XOR\VAR{form
}})
}
766 Evaluate
\SO{TAGBODY
}-like body with
\VAR{var
} successively bound
767 to the elements of
\VAR{list
}. Upon evaluation of
768 \retval{\VAR{result
}},
\VAR{var
} is
\NIL. Implicitly, the whole form
769 is a
\SO{block
} named
\NIL.
775 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
776 \subsection{Loop Facility
}
777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
786 \text{\kwd{loop
}}\text{ }
788 \text{\LKWD{named
} \VAR{n
}\DF{\NIL}}
792 \text{\LKWD{with
} \VAR{var-s
} \Op{\VAR{type
}} \LKWD{=
} \VAR{foo
}}
793 \
{\text{\LKWD{and
} \VAR{var-p
} \Op{\VAR{type
}} \LKWD{=
}
794 \VAR{bar
}\
}}^
{*
} \\
[.1ex
]
801 \text{\VAR{var
} [\VAR{type
}]}
809 \text{\LKWD{upfrom
}}\\
813 \text{\VAR{start
}\DF{\LIT{0}}}
825 \text{\LKWD{from
} \VAR{start
}}
828 \text{\LKWD{downto
}}\\
833 \text{\LKWD{downfrom
} \VAR{start
}}\text{ }
837 \text{\LKWD{downto
}}\\
847 \text{\LKWD{by
} \VAR{step
}\DF{\LIT{1}}}
855 \text{\VAR{list
}}\text{ }
857 \text{\LKWD{by
} \VAR{function
}\DF{\kwd{cdr
}}}
859 \text{\LKWD{=
} \VAR{foo
}}
861 \text{\LKWD{then
} \VAR{bar
}}
863 \text{\LKWD{across
} \VAR{vector
}}\\
877 \text{\LKWD{hash-key
}}\\
878 \text{\LKWD{hash-keys
}}
889 \text{\LKWD{using
} (
\LKWD{hash-value
} \VAR{v
})
}%
893 \text{\LKWD{hash-value
}}\\
894 \text{\LKWD{hash-values
}}
905 \text{\LKWD{using
} (
\LKWD{hash-key
} \VAR{k
})
}%
911 \text{\LKWD{symbol
\Op{s
}}}\\
912 \text{\LKWD{present-symbol
\Op{s
}}}\\
913 \text{\LKWD{external-symbol
\Op{s
}}}
922 \right\
} \text{\VAR{package
}\DF{\V{\A package
\A}}}%
927 \right\
}_
{\displaystyle{\mathbb{F
}_0
}}
930 \text{\LKWD{and
} }\boxed{\mathbb{F
}_i\!
}
935 \text{\LKWD{initially
}} \\
936 \text{\LKWD{finally
}}
939 \text{\VAR{form
}}^
{+
} \\
942 \right\
}^
{\!\!
\displaystyle{*
}}
946 \text{\LKWD{repeat
} \VAR{num
}}\\
949 \text{\LKWD{while
}}\\
950 \text{\LKWD{until
}}\\
951 \text{\LKWD{always
}}\\
952 \text{\LKWD{never
}}\\
953 \text{\LKWD{thereis
}}
966 \text{\VAR{form
}}^
{+
}\\
976 \text{\LKWD{collect
\Op{ing
}}}\\
977 \text{\LKWD{append
\Op{ing
}}}\\
978 \text{\LKWD{nconc
\Op{ing
}}}
986 \right\
} \Op{\text{\LKWD{into
}\VAR{list
}}}\\
989 \text{\LKWD{count
\Op{ing
}}}\\
990 \text{\LKWD{sum
\Op{ming
}}}\\
991 \text{\LKWD{maximize
}}\\
992 \text{\LKWD{maximizing
}}\\
993 \text{\LKWD{minimize
}}\\
994 \text{\LKWD{minimizing
}}
1003 \Op{\text{\LKWD{into
}\VAR{num
}}}\text{ }
1004 \Op{\text{\VAR{type
}}}\\
1008 \text{\LKWD{when
}}\\
1009 \text{\LKWD{unless
}}
1013 \boxed{\mathbb{C
}_i\!
}\
{\text{\LKWD{and
}}\,
1014 \boxed{\mathbb{C
}_j\!
}\
}^
{*
}\Op{\text{\LKWD{else
}}\,
1015 \boxed{\mathbb{C
}_k\!
}\
{\text{\LKWD{and
}}\,
1016 \boxed{\mathbb{C
}_l\!
}\
}^
{*
}}
1017 \Op{\text{\LKWD{end
}}}
1019 \right._
{\!\!\!\!
\displaystyle{\mathbb{C
}_0
}}
1025 \text{\LKWD{initially
}} \\
1026 \text{\LKWD{finally
}}
1029 \text{\VAR{form
}}^
{+
}
1031 \right\
}^
{\displaystyle{\!\!*
}}
1035 \end{center
}\vspace{-
2em
}
1036 \raisebox{0em
}[0em
][0em
]{\parbox[b
]{4cm
}{\caption{\protect\raggedright Loop Facility, Overview.
\label{loop-overview
}}}}
1042 \IT{(
\MC*
{LOOP
} \OPn{\VAR{form
}})
}
1044 Simple Loop. If
\VAR{form
}s do not contain any atomic Loop Facility
1045 keywords, evaluate them forever in an implicit
\SO{block
} named
\NIL.
1048 \IT{(
\MC*
{LOOP
} \OPn{\VAR{form
}})
}
1050 Loop Facility. For Loop Facility keywords
1051 see below and Figure
\ref{loop-overview
}.
1056 \IT{\LKWD*
{named
} \VAR{n
}\DF{\NIL}}
1058 Give
\MC{loop
}'s implicit
\SO{block
} a name.
1061 \IT{\Goop{\LKWD*
{with
} \VAR{var-s
} \Op{\VAR{type
}} \LKWD*
{=
} \VAR{foo
}} \Goos{\LKWD*
{and
}
1062 \VAR{var-p
} \Op{\VAR{type
}} \LKWD*
{=
} \VAR{bar
}}}
1064 Initialize local variables
\VAR{var-s
} sequentially and
\VAR{var-p
} in parallel.
1067 \IT{\Goo{\LKWD*
{initially
}\XOR\LKWD*
{finally
}} \RP{\VAR{form
}}}
1069 Evaluate
\VAR{form
}s before begin, or after end, respectively, of iterations.
1072 \IT{\GOo{\Goo{\LKWD*
{for
}\XOR\LKWD*
{as
}} \XOR\
\LKWD*
{and
}} \VAR{var
} \Op{\VAR{type
}}}
1074 Begin of iteration control clauses;
\VAR{var
}s are initialized and
1075 stepped sequentially/in parallel, respectively.
1080 \IT{\Goo{\LKWD*
{upfrom
}\XOR\LKWD*
{from
}\XOR\LKWD*
{downfrom
}}
1083 Start stepping with
\VAR{start
}
1086 \IT{\Goo{\LKWD*
{upto
}\XOR\LKWD*
{downto
}\XOR\LKWD*
{to
}\XOR\LKWD*
{below
}\XOR\LKWD*
{above
}}
1089 Specify
\VAR{form
} as the end value for stepping.
1092 \IT{\Goo{\LKWD*
{in
}\XOR\LKWD*
{on
}} \VAR{list
}}
1094 Bind
\VAR{var
} to successive elements/tails, respectively, of
\VAR{list
}.
1097 \IT{\LKWD*
{by
} \Goo{\VAR{step
}\DF{\LIT{1}}\XOR\VAR{function
}\DF{\FU{cdr
}}}}
1099 Specify the (positive) decrement or increment or the
1100 \VAR{function
} of one argument returning the next part of the list.
1103 \IT{\LKWD*
{=
} \VAR{foo
} \Op{\LKWD*
{then
}
1104 \VAR{bar
}\DF{\VAR{foo
}}}}
1106 Bind
\VAR{var
} in the first iteration to
\VAR{foo
} and later to
\VAR{bar
}.
1109 \IT{\LKWD*
{across
} \VAR{vector
}}
1111 Bind
\VAR{var
} to successive elements of
\VAR{vector
}.
1114 \IT{\LKWD*
{being
} \Goo{\LKWD*
{the
}\XOR\LKWD*
{each
}}}
1116 Iterate over a hash table or a package.
1121 \IT{\Goo{\LKWD*
{hash-key
}\XOR\LKWD*
{hash-keys
}} \Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
1122 \Op{\LKWD*
{using
} (
\LKWD*
{hash-value
} \VAR{value
})
}}
1124 Bind
\VAR{var
} successively to the keys of
\VAR{hash-table
}; bind
\VAR{value
} to corresponding values.
1127 \IT{\Goo{\LKWD*
{hash-value
}\XOR\LKWD*
{hash-values
}} \Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
1128 \Op{\LKWD*
{using
} (
\LKWD*
{hash-key
} \VAR{key
})
}}
1130 Bind
\VAR{var
} successively to the values of
\VAR{hash-table
}; bind
\VAR{key
} to corresponding keys.
1133 \IT{\Goo{\LKWD*
{symbol
}\XOR\LKWD*
{symbols
}\XOR\LKWD*
{present-symbol
}\XOR\LKWD*
{present-symbols
}\XOR\LKWD*
{external-symbol
}\XOR\LKWD*
{external-symbols
}}
1134 \Op{\Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}}
1135 \VAR{package
}\DF{\V{\A package
\A}}}}
1137 Bind
\VAR{var
} successively to the symbols, or the present
1138 symbols, or the external symbols respectively, of
1145 \IT{\Goo{\LKWD*
{do
}\XOR\LKWD*
{doing
}} \RP{\VAR{form
}}}
1147 Evaluate
\VAR{form
}s in every iteration.
1152 Value of
\VAR{test
} form of an enclosing
\LKWD{if
},
1153 \LKWD{when
},
\LKWD{unless
}, or
\LKWD{else
} clause.
1156 \IT{\LKWD*
{return
} \Goo{\VAR{form
}\XOR\LKWD*
{it
}}}
1158 Return immediately, skipping any
\LKWD{finally
} parts, with value of
\VAR{form
} or
\LKWD{it
}.
1161 \IT{\Goo{\LKWD*
{collect
}\XOR\LKWD*
{collecting
}}
1162 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
} \VAR{list
}}}
1164 Collect values of
\VAR{form
} or
\LKWD{it
} into
\VAR{list
}. If no
1165 \VAR{list
} is given, collect into an anonymous list which is
1166 returned after termination.
1169 \IT{\Goo{\LKWD*
{append
}\XOR\LKWD*
{appending
}\XOR\LKWD*
{nconc
}\XOR\LKWD*
{nconcing
}}
1170 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1173 Concatenate values of
\VAR{form
} or
\LKWD{it
}, which should be
1174 lists, into
\VAR{list
} by the means of
\FU{append
} or
\FU{nconc
},
1175 respectively. If no
\VAR{list
} is given, collect into an
1176 anonymous list which is returned after termination.
1179 \IT{\Goo{\LKWD*
{count
}\XOR\LKWD*
{counting
}}
1180 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1181 \VAR{n
}} \Op{\VAR{type
}}}
1183 Count the number of times the value of
\VAR{form
} or of
\LKWD{it
} is
\T.
1184 If no
\VAR{n
} is given, count into an anonymous variable
1185 which is returned after termination.
1188 \IT{\Goo{\LKWD*
{sum
}\XOR\LKWD*
{summing
}}
1189 \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1190 \VAR{sum
}} \Op{\VAR{type
}}}
1192 Calculate the sum of the values of
\VAR{form
} or of
\LKWD{it
}.
1193 If no
\VAR{sum
} is given, sum into an anonymous variable
1194 which is returned after termination.
1197 \IT{\Goo{\LKWD*
{maximize
}\XOR\LKWD*
{maximizing
}\XOR
1198 \LKWD*
{minimize
}\XOR
1199 \LKWD*
{minimizing
}} \Goo{\VAR{form
}\XOR\LKWD*
{it
}} \Op{\LKWD*
{into
}
1200 \VAR{max-min
}} \Op{\VAR{type
}}}
1202 Determine the maximum or minimum, respectively, of the values of
1203 \VAR{form
} or of
\LKWD{it
}.
1204 If no
\VAR{max-min
} is given, use an anonymous variable
1205 which is returned after termination.
1208 \IT{\Goo{\LKWD*
{if
}\XOR\LKWD*
{when
}\XOR\LKWD*
{unless
}} \VAR{ test
}
1209 \VAR{i-form
} \Goos{\LKWD*
{and
}
1210 \VAR{j-form
}} \Op{\LKWD*
{else
} \VAR{k-form
} \Goos{\LKWD*
{and
}
1211 \VAR{l-form
}}} \Op{\LKWD*
{end
}}}
1213 If
\VAR{test
} returns
\T,
\T, or
\NIL, respectively, evaluate
1214 \VAR{i-form
} and
\VAR{j-form
}s; otherwise, evaluate
\VAR{k-form
}
1215 and
\VAR{l-form
}s. Inside
\VAR{i-form
} and
\VAR{k-form
}, the value
1216 of
\VAR{test
} is accessible by
\LKWD*
{it
}.
1219 \IT{\LKWD*
{repeat
} \VAR{num
}}
1221 Terminate
\MC{loop
} after
\VAR{num
} times;
\VAR{num
} is evaluated once.
1224 \IT{\Goo{\LKWD*
{while
}\XOR\LKWD*
{until
}} \VAR{test
}}
1226 Continue iteration until
\VAR{test
} returns
\NIL\ or
\T, respectively.
1229 \IT{\Goo{\LKWD*
{always
}\XOR\LKWD*
{never
}} \VAR{test
}}
1231 Terminate
\MC{loop
} returning
\NIL\ and skipping any
1232 \LKWD{finally
} parts as soon as
\VAR{test
} is
\NIL\ or
\T,
1233 respectively. Otherwise continue
\MC{loop
} with its default return
1237 \IT{\LKWD*
{thereis
} \VAR{test
}}
1239 Terminate
\MC{loop
} when
\VAR{test
} is
\T\ and return value of
1240 \VAR{test
}, skipping any
\LKWD{finally
} parts. Otherwise continue
1241 \MC{loop
} with its default return value set to
\NIL.
1244 \IT{\LKWD*
{loop-finish
}}
1246 Terminate
\MC{loop
} immediately returning any accumulated results.