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
})
}
20 \retval{\T} if
\VAR{foo
} and
\VAR{bar
} are identical.
22 \IT{(
\FU*
{EQL
} \VAR{foo bar
})
}
23 \retval{\T} if
\VAR{foo
} and
\VAR{bar
}
24 are identical, or are the same character, or are the same number.
26 \IT{(
\FU*
{EQUAL
} \VAR{foo bar
})
}
27 \retval{\T} if
\VAR{foo
} and
\VAR{bar
}
28 are
\FU{EQL
}, or are conses with
\FU{equal
} cars and cdrs, or are
29 strings or bit-vectors with
\FU{eql
} elements, or are equivalent pathnames.
31 \IT{(
\FU*
{EQUALP
} \VAR{foo bar
})
}
32 \retval{\T} if
\VAR{foo
} and
\VAR{bar
}
33 are
\FU{EQUAL
}, or if they have corresponding components of the same
34 type which are
\kwd{equalp
}.
36 \IT{(
\FU*
{CONSTANTP
} \VAR{foo
} \Op{\VAR{environment
}})
}
37 \retval{\T} if
\VAR{foo
} is a constant form.
39 \IT{(
\FU*
{NOT
} \VAR{bool
})
}
40 Return
\retval{\NIL} if
\VAR{bool
} is
\T, return
\retval{\T} if
\VAR{bool
} is
\NIL.
42 \IT{(
\FU*
{FUNCTIONP
} \VAR{foo
})
}
43 \retval{\T} if
\VAR{foo
} is of type
\kwd{function
}.
45 \IT{(
\FU*
{FBOUNDP
} \VAR{foo
})
}
46 \retval{\T} if
\VAR{foo
} is the name of a global function or macro..
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 \subsection{Variables
}
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 \IT{(
\kwd*
{DEFVAR
} \VAR{name
} \OP{\VAR{value
} \Op{\VAR{documentation
}}} )
} Unless bound
59 already, assign
\VAR{value
} to dynamic variable
\retval{\VAR{name
}}.
61 \IT{(
\kwd*
{DEFPARAMETER
} \VAR{name
} \VAR{value
} \Op{\VAR{documentation
}} )
} Assign
62 \VAR{value
} to dynamic variable
\retval{\VAR{name
}}.
64 \IT{(
\kwd*
{DEFCONSTANT
} \VAR{name
} \VAR{value
} \Op{\VAR{documentation
}} )
} Assign
65 \VAR{value
} to global constant
\retval{\VAR{name
}}.
67 \IT{(
\FU*
{NTH-VALUE
} \VAR{n
} \VAR{form
})
}
68 \retval{\VAR{n
}th return value
} of
\VAR{form
}.
70 \IT{(
\xorGOO{\SF*
{SETF
}\\
\SF*
{PSETF
}}{\
}} \Goos{\VAR{place
}
72 Set
\VAR{place
}s to
\retval{\VAR{value
}s
}, resp. Work sequentially/in
75 \IT{(
\xorGOO{\SF*
{SETQ
}\\
\SF*
{PSETQ
}}{\
}} \Goos{\VAR{symbol
}
77 Set
\VAR{symbol
}s to
\retval{\VAR{value
}s
}, resp. Work sequentially/in
80 \IT{(
\SF*
{MULTIPLE-VALUE-SETQ
} \VAR{vars
} \VAR{form
})
}
81 Set
\VAR{vars
} to the respective values returned by
82 \VAR{form
}. Return
\retval{\VAR{form
}'s primary value
}.
84 \IT{(
\SF*
{SHIFTF
} \RP{\VAR{place
}} \VAR{foo
})
} Store
\VAR{foo
} in
85 rightmost
\VAR{place
} shifting values of
\VAR{place
}s left, returning
86 \retval{first
\VAR{place
}}.
88 \IT{(
\SF*
{ROTATEF
} \OPn{\VAR{place
}})
} Rotate values of
\VAR{place
}s left,
89 old first becoming new last
\VAR{place
}. Return
\retval{\NIL}.
91 \label{:property_lists
}
92 \IT{\arrGOO{(
\FU*
{GET
} \VAR{ symbol
} \VAR{ key
} \OP{\VAR{default
}\DF{\NIL}})\\
93 (
\FU*
{GETF
} \VAR{ place
} \VAR{ key
} \OP{\VAR{default
}\DF{\NIL}})
}{\
}}}
94 \retval{First entry
\VAR{key
}} from property list stored in
95 \VAR{symbol
}/in
\VAR{place
}, resp., or
\retval{\VAR{default
}} if
96 there was no
\VAR{key
}.
\kwd{setf
}able.
98 \IT{(
\FU*
{GET-PROPERTIES
} \VAR{plist
} \VAR{key-list
})
}
99 Return
\retval{Key
} and
\retvalii{value
} of first entry from
\VAR{plist
}
100 matching a key from
\VAR{key-list
}, and
\retvaliii{tail of
101 \VAR{plist
}} starting with
\VAR{key
}. Return
\retval{\NIL},
102 \retvalii{\NIL}, and
\retvaliii{\NIL} if there was no
\VAR{key
}.
104 \IT{\arrGOO{(
\FU*
{REMPROP
} \VAR{ symbol
} \VAR{ key
})\\
105 (
\SF*
{REMF
} \VAR{ place
} \VAR{ key
})
}{\
}}}
106 Remove fist entry
\VAR{key
} from property list stored in
107 \VAR{symbol
}/in
\VAR{place
}, resp. Return
\retval{\T} if
\VAR{key
}
108 was there, or
\retval{\NIL} otherwise.
113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 \subsection{Functions
}
115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 \label{section:Functions
}
119 Below, lambda list
\OPn{\VAR{fu-arg
}} has the form
121 \OP{\kwd*
{\&optional
} \Goos{\VAR{var
}\XOR(
\VAR{var
} \OP{\VAR{init
}
122 \Op{\VAR{supplied-p
}}})
}}
123 \Op{\kwd*
{\&rest
} \VAR{var
}}
124 \OP{\kwd*
{\&key
} \GOos{\VAR{var
}\XOR(
\Goo{\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
126 \OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}
127 \Op{\kwd*
{\&allow-other-keys
}}}
128 \OP{\kwd*
{\&aux
}\Goos{\VAR{var
}\XOR(
\VAR{var
} \Op{\VAR{init
}})
}}
129 ).
\VAR{supplied-p
} is
\T\ if there is a corresponding argument.
133 \IT{(
\xorGOO{\SF*
{DEFUN
} \VAR{ foo
}\\
\SF*
{LAMBDA
}}{\
}}
134 (
\VAR{\OPn{fu-arg
}})
\OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
135 \Op{\VAR{documentation
}}
137 Define function with
\retval{name
\VAR{foo
}} or an anonymous
138 function, resp., which
139 applies
\VAR{form
}s to
\VAR{fu-arg
}s.
141 \IT{(
\xorGOO{\SF*
{FLET
}\\
\SF*
{LABELS
}}{\
}}%
144 \OPn{(
\kwd{declare
} \OPn{\VAR{local-decl
}})
}%
145 \Op{\VAR{documentation
}}
146 \OPn{\VAR{local-form
}})
})
\OPn{(
\kwd{declare
} \VAR{decl
})
}
148 Evaluate
\VAR{form
}s with
149 locally defined functions
\OPn{\VAR{name
}}. Only for
\SF{LABELS
},
150 \VAR{name
}s are visible inside
\VAR{local-forms
}. Return
151 \retval{values of
\VAR{form
}s
}.
153 \IT{(
\SF*
{FUNCTION
} \VAR{foo
})
} Return
\retval{function named
\VAR{foo
}}.
155 \IT{(
\FU*
{APPLY
} \VAR{function
} \RP{\VAR{arg
}})
}
156 Return
\retval{value of
\VAR{function
}} called with
157 \VAR{arg
}s. Last
\VAR{arg
} must be a list.
159 \IT{(
\FU*
{FUNCALL
} \VAR{function
} \OPn{arg
})
}
160 Return
\retval{value of
\VAR{function
}} called with
\VAR{arg
}s.
162 \IT{(
\SF*
{MULTIPLE-VALUE-CALL
} \VAR{foo
} \OPn{\VAR{form
}})
} Call function
163 \VAR{foo
} with values of
\VAR{form
}s as its arguments. Return
164 \retval{values returned by
\VAR{foo
}}.
166 \IT{(
\FU*
{VALUES-LIST
} \VAR{list
})
}
167 Return
\retval{elements of
\VAR{list
}}.
169 \IT{(
\FU*
{VALUES
} \OPn{\VAR{foo
}})
}
170 Return
\retval{\VAR{foo
}s
} as multiple values.
\kwd{setf
}able.
172 \IT{(
\FU*
{MULTIPLE-VALUE-LIST
} \OPn{\VAR{form
}})
}
173 Return
\retval{values of
\VAR{form
}s
}.
175 \IT{(
\FU*
{COMPLEMENT
} \VAR{function
})
}
176 Return
\retval{new function
} with same arguments and same side effects
177 as
\VAR{function
}, but with complementary truth value.
179 \IT{(
\FU*
{CONSTANTLY
} \VAR{foo
})
}
180 Return
\retval{function
} returning
\VAR{foo
}.
182 \IT{(
\FU*
{IDENTITY
} \VAR{foo
})
}
183 Return
\retval{\VAR{foo
}}.
185 \IT{(
\FU*
{FUNCTION-LAMBDA-EXPRESSION
} \VAR{function
})
}
186 If available, return
\retval{Lambda expression
} of
\VAR{function
},
187 \retvalii{\NIL} if
\VAR{function
} was
188 defined in null environment, and
\retvaliii{name
} of
\VAR{function
}.
190 \IT{(
\FU*
{FDEFINITION
} \VAR{foo
})
}
191 \retval{Definition
} of function
\VAR{foo
}.
\kwd{setf
}able.
193 \IT{(
\FU*
{FMAKUNBOUND
} \VAR{name
})
}
194 Remove global function or macro definition
\retval{\VAR{name
}}.
196 \IT{\arrGOO{\CNS*
{CALL-ARGUMENTS-LIMIT
}\\
197 \CNS*
{LAMBDA-PARAMETERS-LIMIT
}}{\
}}}
198 Upper bound of the number of function arguments or lambda list parameters, resp.; $>=
50$.
200 \IT{\CNS*
{MULTIPLE-VALUES-LIMIT
}}
201 Upper bound of the number of values a function can return; $>
20$.
206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
210 Below, macro lambda list
\OPn{\VAR{macro-arg
}} has the form of either
211 (
\Op{\kwd*
{\&whole
} \VAR{var
}}%
212 \Op{\kwd*
{\&environment
} \VAR{var
}}
214 \Op{\kwd*
{\&environment
} \VAR{var
}}
215 \Op{\kwd*
{\&optional
}\Goos{\VAR{var
}\XOR(
\VAR{var
} \Op{\VAR{init
}
216 \Op{\VAR{supplied-p
}}})
}}
217 \Op{\kwd*
{\&environment
} \VAR{var
}}
218 \Op{\Goo{\kwd*
{\&rest
}\XOR\kwd*
{\&body
}} \VAR{var
}}
219 \Op{\kwd*
{\&environment
} \VAR{var
}}
220 \OP{\kwd*
{\&key
}\GOos{\VAR{var
}\XOR(
\Goo{\VAR{var
}\XOR(
\kwd{:
}\VAR{key
}
222 \OP{\VAR{init
}\Op{\VAR{supplied-p
}}})
}%
223 \Op{\kwd*
{\&environment
} \VAR{var
}}
224 \Op{\kwd*
{\&allow-other-keys
}}}
225 \Op{\kwd*
{\&aux
}\Goos{\VAR{var
}\XOR(
\VAR{var
} \Op{\VAR{init
}})
}}%
226 \Op{\kwd*
{\&environment
} \VAR{var
}}
229 (
\Op{\kwd*
{\&whole
} \VAR{var
}}%
230 \Op{\kwd*
{\&environment
} \VAR{var
}}
232 \Op{\kwd*
{\&environment
} \VAR{var
}}
233 \Op{\kwd*
{\&optional
}\Goos{\VAR{var
}\XOR(
\VAR{var
} \Op{\VAR{init
}
234 \Op{\VAR{supplied-p
}}})
}}
235 \Op{\kwd*
{\&environment
} \VAR{var
}}
237 \kwd*
{\&environment
} \VAR{var
} may appear only once.
238 \VAR{supplied-p
} is
\T\ if there is a corresponding argument.
243 \IT{(
\xorGOO{\SF*
{DEFMACRO
}\\
\FU*
{DEFINE-COMPILER-MACRO
}}{\
}}
244 \VAR{name
} \OPn{\VAR{macro-arg
}}
245 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
} \Op{\VAR{documentation
}}
247 Define macro
\retval{\VAR{name
}}.
249 \IT{(
\SF*
{MACROLET
} (
\OPn{(
\OPn{name
} \OPn{\VAR{macro-arg
}}
250 \OPn{(
\kwd{declare
} \OPn{\VAR{local-decl
}})
}
251 \Op{\VAR{documentation
}} \OPn{form
})
})
\OPn{(
\kwd{declare
}
252 \OPn{\VAR{decl
}})
} \OPn{\VAR{body
}})
}
253 Evaluate
\retval{\OPn{\VAR{body
}}} with
\VAR{name
}s locally defined
254 as corresponding macros which are invisible to each other.
256 \IT{(
\SF*
{SYMBOL-MACROLET
} (
\OPn{(
\VAR{name
}
257 \OPn{\VAR{form
}})
})
\OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
259 Evaluate
\retval{\OPn{\VAR{body
}}} with
\VAR{name
}s locally defined as
260 corresponding symbol-macros.
262 \IT{(
\SF*
{DEFSETF
} \VAR{function
}\xorGOO{\VAR{update
} \Op{\VAR{documentation
}}\\
263 \OPn{\VAR{arg
} (
\OPn{\VAR{var
}})
\OPn{(
\kwd{declare
} \OPn{\VAR{
264 decl
}})
} \Op{\VAR{documentation
}}}}{\
}})
}
265 Specify how to
\kwd{setf
} a place accessed by
266 \retval{\VAR{function
}} if
\VAR{function
} evaluates all its
269 \IT{(
\SF*
{DEFINE-SETF-EXPANDER
} \VAR{function
} \OPn{\VAR{macro-arg
}}
270 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
} \Op{\VAR{documentation
}}
272 Specify how to
\kwd{setf
} a place accessed by
\retval{\VAR{function
}}.
274 \IT{(
\SF*
{DEFINE-MODIFY-MACRO
} \VAR{name
} (
\kwd{\&optional
}
275 \OPn{\VAR{var
}} \kwd{\&rest
} \OPn{\VAR{var
}})
\VAR{function
}
277 Define macro
\retval{\VAR{name
}} able to read and write a place. On
278 invokation, after applying
\VAR{function
} to place its return value
281 \IT{(
\FU*
{GET-SETF-EXPANSION
} \VAR{place
} \Op{\VAR{environment
}})
}
282 Return five values describing how to
\kwd{setf
} place.
284 \IT{\CNS*
{LAMBDA-LIST-KEYWORDS
}} List of macro lambda list keywords.
289 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
290 \subsection{Control Flow
}
291 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
294 \IT{(
\SF*
{IF
} \VAR{test
} \VAR{then
} \Op{\VAR{else
}})
} Evaluate and return
295 \retval{\VAR{then
}} if
\VAR{test
} returns
\T, evaluate and return
296 \retval{\VAR{else
}} otherwise.
298 \IT{(
\SF*
{COND
} \OPn{(
\VAR{test
} \OPn{\VAR{then
}})
})
}
299 Evaluate and return the
300 \retval{\VAR{then
}s
} whose
\VAR{test
} returns
\T, return
301 \retval{\NIL} if all
\VAR{test
}s return
\NIL.
303 \IT{(
\xorGOO{\SF*
{WHEN
}\\
\SF*
{UNLESS
}}{\
}} \VAR{test
} \OPn{\VAR{foo
}})
}
304 Evaluate
\VAR{foo
}s and return
\retval{value of last
\VAR{foo
}} if
305 \VAR{test
} returns
\T\ or
\NIL, resp. Return
\retval{\NIL} otherwise.
307 \IT{(
\SF*
{CASE
} \VAR{object
} \GOOs{(
\GOop{\VAR{key
}}\Goos{\VAR{foo
}})
}
308 \Op{(
\Goo{\LIT{t
}\XOR\kwd*
{OTHERWISE
}}\Goos{\VAR{foo
}})
})
}
309 Evaluate first
\VAR{foo
}s whose unevaluated
\VAR{key
} is either
\kwd{eql
} evaluated
310 \VAR{object
} or
\LIT{t
} or
\LIT{otherwise
}. Return
\retval{value of
311 last evaluated
\VAR{foo
}}.
313 \IT{(
\Goo{\SF*
{CCASE
}\XOR\SF*
{ECASE
}} \VAR{object
} \Goos{(
\GOop{\VAR{key
}}\Goos{\VAR{foo
}})
})
}
314 Evaluate first
\VAR{foo
}s whose unevaluated
\VAR{key
} is
\kwd{eql
} evaluated
315 \VAR{object
}. Return
\retval{value of last evaluated
316 \VAR{foo
}}. Signal correctible error/non-correctible error,
317 resp., if no
\VAR{key
} matches and return
\retval{\NIL} then.
319 \IT{(
\SF*
{AND
} \OPn{\VAR{form
}})
} Evaluate
\VAR{form
}s from left to
320 right. Immediately return
\retval{\NIL} if one
\VAR{form
}'s value is
\NIL. Return
321 \retval{value of last
\VAR{form
}} otherwise. Without any
\VAR{form
}
324 \IT{(
\SF*
{OR
} \OPn{\VAR{form
}})
} Evaluate
\VAR{form
}s from left to
325 right. Immediately return
\retval{value of first non-
\NIL-evaluating
326 form
}. Return
\retval{\NIL} if no
\VAR{form
} returns true.
327 Return
\retval{value of last
\VAR{form
}} otherwise.
329 \IT{(
\kwd*
{PROGN
} \OPn{\VAR{form
}})
} Sequence
\VAR{form
}s. Return
330 \retval{value of last
\VAR{form
}}.
332 \IT{(
\xorGOO{\SF*
{PROG
}\\
336 (
\VAR{var
} \Op{ \VAR{value
}})
}{\
}^
{\!\!*
}})
337 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
338 \xorGOO{\VAR{tag
}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
339 Evaluate
\kwd{TAGBODY
}-like body with locally bound
340 \VAR{var
}s. Return
\retval{\NIL} or explicitly
\retval{\kwd{return
}ed value
}.
343 (
\SF*
{MULTIPLE-VALUE-PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
344 (
\SF*
{PROG1
} \VAR{ form-r
} \OPn{\VAR{ form
}})\\
345 (
\SF*
{PROG2
} \VAR{ form-a
} \VAR{ form-r
} \OPn{\VAR{ form
}})
}{\
}}}
346 Evaluate all forms in order. Return
\retval{values/
1st value of
\VAR{form-r
}}.
348 \IT{(
\SF*
{PROGV
} \VAR{symbols
} \VAR{values
} \OPn{form
})
}
349 Evaluate
\VAR{form
}s with
\VAR{symbols
} dynamically bound to
\VAR{values
} or
350 \NIL. Return
\retval{values returned by
\VAR{form
}s
}.
352 \IT{(
\SF*
{DESTRUCTURING-BIND
} \VAR{foo
} \VAR{bar
} \OPn{(
\kwd{declare
}
353 \OPn{\VAR{decl
}})
} \OPn{\VAR{form
}})
} Evaluate
\VAR{form
}s, and return
354 \retval{value of last
\VAR{form
}}, with
355 variables from tree
\VAR{foo
} bound to corresponding elements of tree
\VAR{bar
}.
357 \IT{(
\kwd*
{MULTIPLE-VALUE-BIND
} (
\OPn{\VAR{var
}})
\VAR{values-form
}
358 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
} \OPn{\VAR{body-form
}})
} Evaluate
359 body with
\VAR{var
}s bound to the return values of
360 \VAR{values-form
}. Return
\retval{values returned by
\VAR{body-form
}s
}.
362 \IT{(
\xorGOO{\SF*
{LET
}\\
365 (
\VAR{name
}\Op{\VAR{value
}})
}{\
}^
{\!\!*
}})
366 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
368 Evaluate
\OPn{\VAR{body
}} with
\VAR{name
}s bound to
\VAR{value
}s or
369 \NIL. Return
\retval{values returned by
\OPn{\VAR{body
}}}. In
\SF{LET*
},
370 \VAR{value
}s can refer to previous
\VAR{name
}s.
372 \IT{(
\SF*
{LOCALLY
} \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
374 Evaluate
\OPn{\VAR{body
}} with declarations
\VAR{decl
} in
375 effect. Return
\retval{values returned by
\OPn{\VAR{body
}}}.
377 \IT{(
\SF*
{RETURN-FROM
} \VAR{foo
} \Op{result
})
} Have nearest enclosing
378 \kwd{block
} \VAR{foo
} return with
\VAR{result
}.
380 \IT{(
\SF*
{RETURN
} \Op{result
})
}
381 Have enclosing block return with
\retval{\VAR{result
}}.
383 \IT{(
\SF*
{BLOCK
} \VAR{name
} \OPn{\VAR{form
}})
} Evaluate
\VAR{form
}s returning
384 \retval{value of last
\VAR{form
}} unless interrupted by
\SF{RETURN-FROM
}.
386 \IT{(
\SF*
{TAGBODY
} \Goos{\VAR{tag
}\XOR\VAR{form
}})
}
387 Evaluate
\VAR{form
}s.
\VAR{tag
}s (symbols or integers) are targets
388 for
\SF{GO
}. Return
\retval{\NIL}.
390 \IT{(
\SF*
{GO
} \VAR{tag
})
} Jump within a
\SF{tagbody
} to nearest
391 lexically enclosing
\kwd{eql
} \VAR{tag
}.
393 \IT{(
\SF*
{CATCH
} \VAR{tag
} \OPn{\VAR{form
}})
} Evaluate
\VAR{form
}s returning
394 \retval{value of last
\VAR{form
}} unless interrupted by
\SF{THROW
}.
396 \IT{(
\SF*
{THROW
} \VAR{tag form
})
} Have the nearest dynamically
397 enclosing
\SF{CATCH
} with a tag
\kwd{eq
} \VAR{tag
} return with the
400 \IT{(
\FU*
{BREAK
} \VAR{control
} \OPn{args
})
}
401 Jump into debugger, return
\retval{\NIL}.
402 See p.\
\pageref{section:Format
},
\kwd{format
}, for
\VAR{control
}
405 \IT{(
\FU*
{SLEEP
} \VAR{n
})
} Wait
\VAR{n
} seconds, return
\retval{\NIL}.
411 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
412 \subsection{Iteration
}
413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
417 \IT{(
\xorGOO{\SF*
{DO
}\\
\SF*
{DO*
}}{\
}}
420 (
\VAR{var
} \Op{ \VAR{start
} \Op{\VAR{step
}}})
}{\
}^
{\!\!*
}})
421 (
\VAR{stop
} \OPn{\VAR{result
}})
422 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
}
423 \xorGOO{\VAR{tag
}\\
\VAR{form
}}{\
}^
{\!\!*
}})
}
424 Evaluate
\SF{TAGBODY
}-like body with
\VAR{var
}s successively bound according
425 to the values of the corresponding
\VAR{start
} and
\VAR{step
}
426 forms.
\VAR{var
}s are bound in parallel/sequentially, resp.
427 Stop iteration when
\VAR{stop
} is
\T. Return
\retval{value of
430 \IT{(
\SF*
{DOTIMES
} (
\VAR{var
} \VAR{integer
} \Op{\VAR{result
}})
431 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
} \Goos{\VAR{tag
}\XOR\VAR{form
}})
}
432 Evaluate
\SF{TAGBODY
}-like body with
\VAR{var
} successively bound
433 to integers from
0 to $
\mbox{\VAR{integer
}} -
1$. Upon evaluation of
434 \retval{\VAR{result
}},
\VAR{var
} is
\NIL.
436 \IT{(
\SF*
{DOLIST
}(
\VAR{var
} \VAR{list
} \Op{\VAR{result
}})
437 \OPn{(
\kwd{declare
} \OPn{\VAR{decl
}})
} \Goos{\VAR{tag
}\XOR\VAR{form
}})
}
438 Evaluate
\SF{TAGBODY
}-like body with
\VAR{var
} successively bound
439 to the elements of
\VAR{list
}. Upon evaluation of
440 \retval{\VAR{result
}},
\VAR{var
} is
\NIL.
445 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
446 \subsection{Loop Facility
}
447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
450 \label{loop-overview
}%
458 \text{\LKWD{named
} \VAR{n
}}
462 \text{\LKWD{with
} \VAR{var
} [\VAR{type
}] \LKWD{=
} \VAR{foo
}}
463 \
{\text{\LKWD{and
} \VAR{var-n
} [\VAR{type
}] \LKWD{=
} \VAR{bar
}\
}}^
{*
} \\
470 \text{\VAR{var
} [\VAR{type
}]}
478 \text{\LKWD{upfrom
}}\\
482 \text{\VAR{start
}\DF{0}}
494 \text{\LKWD{from
} \VAR{start
}}
497 \text{\LKWD{downto
}}\\
502 \text{\LKWD{downfrom
} \VAR{start
}}
506 \text{\LKWD{downto
}}\\
516 \text{\LKWD{by
} \VAR{step
}\DF{1}}
526 \text{\LKWD{by
} \VAR{form
}\DF{\kwd{\#'cdr
}}}
528 \text{\LKWD{=
} \VAR{foo
}}
530 \text{\LKWD{then
} \VAR{bar
}}
532 \text{\LKWD{across
} \VAR{vector
}}\\
546 \text{\LKWD{hash-key
}}\\
547 \text{\LKWD{hash-keys
}}
558 \text{\LKWD{using
} (
\LKWD{hash-value
} \VAR{v
})
}
562 \text{\LKWD{hash-value
}}\\
563 \text{\LKWD{hash-values
}}
574 \text{\LKWD{using
} (
\LKWD{hash-key
} \VAR{k
})
}
580 \text{\LKWD{symbol
\Op{s
}}}\\
581 \text{\LKWD{present-symbol
\Op{s
}}}\\
582 \text{\LKWD{external-symbol
\Op{s
}}}
591 \right\
} \text{\VAR{package
}\DF{\V{*package*
}}}
596 \right\
}_
{\displaystyle{\mathbb{F
}_0
}}
599 \text{\LKWD{and
} }\boxed{\mathbb{F
}_i
}
603 \text{\LKWD{initially
}} \\
604 \text{\LKWD{finally
}}
607 \text{\VAR{form
}}^
{+
} \\
610 \right\
}^
{\!\!
\displaystyle{*
}}
614 \text{\LKWD{repeat
} \VAR{num
}}\\
617 \text{\LKWD{while
}}\\
618 \text{\LKWD{until
}}\\
619 \text{\LKWD{always
}}\\
620 \text{\LKWD{never
}}\\
621 \text{\LKWD{thereis
}}
634 \text{\VAR{form
}}^
{+
}\\
644 \text{\LKWD{collect
\Op{ing
}}}\\
645 \text{\LKWD{append
\Op{ing
}}}\\
646 \text{\LKWD{nconc
\Op{ing
}}}
654 \right\
} [\text{\LKWD{into
}\VAR{var
}}]\\
657 \text{\LKWD{count
\Op{ing
}}}\\
658 \text{\LKWD{sum
\Op{ming
}}}\\
659 \text{\LKWD{maximize
}}\\
660 \text{\LKWD{maximizing
}}\\
661 \text{\LKWD{minimize
}}\\
662 \text{\LKWD{minimizing
}}
671 [\text{\LKWD{into
}\VAR{n
}}]
672 [\text{\VAR{type
}}]\\
681 \boxed{\mathbb{S
}_i
}\
{\text{\LKWD{and
}}%
682 \boxed{\mathbb{S
}_j
}\
}^
{*
}[\text{\LKWD{else
}}%
683 \boxed{\mathbb{S
}_k
}\
{\text{\LKWD{and
}}%
684 \boxed{\mathbb{S
}_l
}\
}^
{*
}][\text{\LKWD{end
}}]
686 \right._
{\displaystyle{\mathbb{S
}_0
}}
691 \text{\LKWD{initially
}} \\
692 \text{\LKWD{finally
}}
695 \text{\VAR{form
}}^
{+
}
697 \right\
}^
{\displaystyle{\!\!*
}}
701 \end{center
}\vspace{-
1em
}
702 \caption{Loop Facility, Overview.
}%
708 \IT{(
\SF*
{LOOP
} \OPn{\VAR{form
}})
}
709 Simple Loop. If
\VAR{form
}s do
710 not include any keywords of the Loop Facility, evaluate them forever.
712 \IT{(
\SF*
{LOOP
} \OPn{\VAR{form
}})
}
713 Loop Facility. If there are loop facility keywords in
\VAR{form
}s
714 see below and p.\
\pageref{loop-overview
}.
718 \IT{\LKWD*
{named
} \VAR{n
}}
719 Gives implicit
\kwd{block
} of loop a name.
721 \IT{\LKWD*
{with
} \VAR{var
} \LKWD*
{=
} \VAR{foo
} \Op{\VAR{type
}} \Goo{\LKWD*
{and
}
722 \VAR{var-n
} \Op{\VAR{type
}} \LKWD*
{=
} \VAR{bar
}}}
723 Initialize local variables in parallel.
725 \IT{\Goo{\LKWD*
{initially
}\XOR\LKWD*
{finally
}} \RP{\VAR{form
}}}
726 Evaluate
\VAR{form
} before begin, or after end, resp., of iterations.
728 \IT{\Goo{\LKWD*
{for
}\XOR\LKWD*
{as
}} \VAR{var
} \VAR{type
}}
729 Begin of iteration control clause.
733 \IT{\Goo{\LKWD*
{upfrom
}\XOR\LKWD*
{from
}\XOR\LKWD*
{downfrom
}} \VAR{start
}}
734 Start stepping with
\VAR{form
}
736 \IT{\Goo{\LKWD*
{upto
}\XOR\LKWD*
{downto
}\XOR\LKWD*
{to
}\XOR\LKWD*
{below
}\XOR\LKWD*
{above
}} \VAR{form
}}
737 Specify
\VAR{form
} as the end value for stepping.
739 \IT{\Goo{\LKWD*
{in
}\XOR\LKWD*
{on
}} \VAR{list
}}
740 Bind
\VAR{var
} to successive elements/tails, resp., of
\VAR{list
}.
742 \IT{\LKWD*
{by
} \VAR{step
}\DF{1}}
743 Specify the (positive) decrement or increment.
745 \IT{\LKWD*
{=
} \VAR{foo
} \Op{\LKWD*
{then
} \VAR{bar
}\DF{\VAR{foo
}}}}
746 Bind
\VAR{var
} in the first iteration to
\VAR{foo
} and later to
\VAR{bar
}.
748 \IT{\LKWD*
{across
} \VAR{vector
}}
749 Bind
\VAR{var
} to successive elements of
\VAR{vector
}.
751 \IT{\LKWD*
{being
}\Goo{\LKWD*
{the
}\XOR\LKWD*
{each
}}}
752 Iterate over a hash table or a package.
756 \IT{\Goo{\LKWD*
{hash-key
}\XOR\LKWD*
{hash-keys
}}\Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
757 \Op{\LKWD*
{using
} (
\LKWD*
{hash-value
} \VAR{value
})
}}
758 Bind
\VAR{var
} successively to the keys of
\VAR{hash-table
}; bind corresponding values to
\VAR{value
}.
760 \IT{\Goo{\LKWD*
{hash-value
}\XOR\LKWD*
{hash-values
}}\Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{hash-table
}
761 \Op{\LKWD*
{using
} (
\LKWD*
{hash-key
} \VAR{key
})
}}
762 Bind
\VAR{var
} successively to the values of
\VAR{hash-table
}; bind corresponding keys to
\VAR{key
}.
764 \IT{\Goo{\LKWD*
{symbol
}\XOR\LKWD*
{symbols
}\XOR\LKWD*
{present-symbol
}\XOR\LKWD*
{present-symbols
}\XOR\LKWD*
{external-symbol
}\XOR\LKWD*
{external-symbols
}}\Op{\Goo{\LKWD*
{of
}\XOR\LKWD*
{in
}} \VAR{package
}}}
765 Bind
\VAR{var
} successively to the symbols, or the present symbols, or the external symbols, resp., of
\VAR{package
}.
770 \IT{\LKWD*
{and
} \VAR{var
}}
771 Begin of another iteration control clause with variables initialized and stepped in parallel.
773 \IT{\Goo{\LKWD*
{do
}\XOR\LKWD*
{doing
}} \RP{\VAR{form
}}}
774 Evaluate
\VAR{form
}s in every iteration.
776 \IT{\LKWD*
{return
} \Goo{\VAR{form
}\XOR\LKWD*
{it
}}}
777 Return immediately with return value
\VAR{form
}.
779 \IT{\Goo{\LKWD*
{collect
}\XOR\LKWD*
{collecting
}}\Goo{\VAR{form
}\XOR\LKWD*
{it
}}\Op{\LKWD*
{into
} \VAR{list
}}}
780 Collect values of
\VAR{form
} into
\VAR{list
}. If no
\VAR{list
} is given, collect into an anonymous list
781 which is returned after termination.
783 \IT{\Goo{\LKWD*
{append
}\XOR\LKWD*
{appending
}\XOR\LKWD*
{nconc
}\XOR\LKWD*
{nconcing
}}\Goo{\VAR{form
}\XOR\LKWD*
{it
}}\Op{\LKWD*
{into
} \VAR{list
}}}
784 Concatenate values of
\VAR{form
}, which must be lists, into
\VAR{list
} by the means of
\FU{append
}
785 or
\FU{nconc
}, resp. If no
\VAR{list
} is given, collect into an anonymous list
786 which is returned after termination.
788 \IT{\Goo{\LKWD*
{count
}\XOR\LKWD*
{counting
}}\Goo{\VAR{form
}\XOR\LKWD*
{it
}}\Op{\LKWD*
{into
} \VAR{n
}}}
789 Count the number of times
\VAR{form
} returns
\T.
791 \IT{\Goo{\LKWD*
{sum
}\XOR\LKWD*
{summing
}}\Goo{\VAR{form
}\XOR\LKWD*
{it
}}\Op{\LKWD*
{into
} \VAR{sum
}}}
792 Calculate the sum of the values of
\VAR{form
}.
794 \IT{\Goo{\LKWD*
{maximize
}\XOR\LKWD*
{maximizing
}\XOR
796 \LKWD*
{minimizing
}}\Goo{\VAR{form
}\XOR\LKWD*
{it
}}\Op{\LKWD*
{into
}
798 Determine the maximum or minimum, resp., of all values of
801 \IT{\Goo{\LKWD*
{if
}\XOR\LKWD*
{when
}\XOR\LKWD*
{unless
}}\VAR{ test
}
802 \VAR{form-i
} \Goos{\LKWD*
{and
}
803 \VAR{form-j
}}\Op{\LKWD*
{else
} \VAR{form-k
} \Goos{\LKWD*
{and
}
804 \VAR{form-l
}}} \Op{\LKWD*
{end
}}}
805 If
\VAR{test
} returns
\T,
\T, or
\NIL, resp., evaluate
806 \VAR{form-i
} and
\VAR{form-j
}s; otherwise, evaluate
\VAR{form-k
}
807 and
\VAR{form-l
}s. Inside
\VAR{form-i
} and
\VAR{form-k
}, the value
808 of
\VAR{test
} is accessible by
\LKWD*
{it
}.
810 \IT{\LKWD*
{repeat
} \VAR{num
}}
811 Terminate
\SF{loop
} after
\VAR{num
} times;
\VAR{num
} is evaluated once.
813 \IT{\Goo{\LKWD*
{while
}\XOR\LKWD*
{until
}} \VAR{test
}}
814 Continue iteriation until
\VAR{test
} returns
\NIL, or
\T, resp.
816 \IT{\Goo{\LKWD*
{always
}\XOR\LKWD{never
}} \VAR{test
}}
817 Terminate
\SF{loop
} returning
\NIL\ and skipping any
\LKWD*
{finally
} parts as soon as
\VAR{test
} is
\NIL, or
\T, resp. Otherwise continue
\SF{loop
} with its default return value set to
\T.
819 \IT{\LKWD*
{thereis
} \VAR{test
}}
820 Terminate
\SF{loop
} when
\VAR{test
} is
\T\ and return value of
\VAR{form
}, skipping any
\LKWD*
{finally
} parts. Otherwise continue
\SF{loop
} with its default return value set to
\T.
822 \IT{\LKWD*
{loop-finish
}}
823 Terminate
\SF{loop
} immediately; skip any
\LKWD*
{finally
} parts