Move entries on let etc. to section Variables
[clqr.git] / clqr-conditions-and-errors.tex
blob727cde584ccb41640140c544c25baab729946577
1 % Copyright (C) 2008, 2009, 2010, 2011 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{Conditions and Errors}
12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 For standardized condition types cf.\ Figure \ref{data-types} on
15 page \pageref{data-types}.
17 \begin{LIST}{1cm}
18 \IT{(\MC*{DEFINE-CONDITION} \VAR{foo} (\OPn{\VAR{parent-type}}\DF{\kwd{condition}})
19 (\xorGOO{\VAR{slot}\\
20 (\VAR{slot }
21 \orGOO{\Goos{\kwd{:reader} \VAR{reader}}\\
22 \Goos{\kwd{:writer} \xorGOO{%
23 \VAR{writer}\\
24 (\kwd{setf } \VAR{writer})}{\}}}\\
25 \Goos{\kwd{:accessor} \VAR{accessor}} \\
26 \kwd{:allocation } \xorGOO{\kwd{:instance}\\
27 \kwd{:class}}{\}}\DF{\kwd{:instance}}\\
28 \Goos{\kwd{:initarg} \kwd{:}\VAR{initarg-name}}\\
29 \kwd{:initform} \VAR{ form}\\
30 \kwd{:type} \VAR{ type}\\
31 \kwd{:documentation} \VAR{ slot-doc}%
32 }{\}})}{\}^{\!\!*}})
33 \orGOO{(\kwd{:default-initargs } \Goos{\VAR{name} \VAR{value}})\\
34 ({\kwd{:documentation} \VAR{ condition-doc}})\\
35 (\kwd{:report } \xorGOO{\VAR{string}\\
36 \VAR{report-function}}{\}})}{\}})}
38 Define, as a subtype of \VAR{parent-type}s, condition type
39 \retval{\VAR{foo}}. In a new condition, a \VAR{slot}'s value defaults
40 to \VAR{form} unless set via \kwd{:}\VAR{initarg-name}; it is readable
41 via (\VAR{reader} \VAR{i}) or (\VAR{accessor} \VAR{i}), and
42 writeable via (\VAR{writer} \VAR{value} \VAR{i}) or (\kwd{setf}
43 (\VAR{accessor} \VAR{i}) \VAR{value}). With
44 \kwd{:allocation :class}, \VAR{slot} is shared by all conditions of
45 type \VAR{foo}. A condition is reported by \VAR{string} or by
46 \VAR{report-function} of arguments condition and stream.
49 \IT{(\FU*{MAKE-CONDITION} \VAR{type} \Goos{\kwd{:}\VAR{initarg-name} \VAR{value}})}
51 Return new \retval{condition of \VAR{type}}.
54 \IT{(\xorGOO{%
55 \FU*{SIGNAL}\\
56 \FU*{WARN}\\
57 \FU*{ERROR}%
58 }{\}}
59 \xorGOO{%
60 \VAR{condition}\\
61 \VAR{type}\text{ } \Goos{\kwd{:}\VAR{initarg-name} \VAR{value}}\\
62 \VAR{control}\text{ } \OPn{\VAR{arg}}%
63 }{\}})}
65 Unless handled, signal as \kwd{condition}, \kwd{warning} or \kwd{error},
66 respectively, \VAR{condition} or a new condition of \VAR{type} or,
67 with \FU{format} \VAR{control} and \VAR{arg}s (see p.\ \pageref{section:Format}),
68 \kwd{simple-condition}, \kwd{simple-warning}, or \kwd{simple-error}, respectively.
69 From \FU{SIGNAL} and \FU{WARN}, return \retval{\NIL}.
72 \IT{(\FU*{CERROR} \VAR{continue-control}
73 \xorGOO{%
74 \VAR{condition}\text{ } \OPn{\VAR{continue-arg}}\\
75 \VAR{type}\text{ } \Goos{\kwd{:}\VAR{initarg-name} \VAR{value}}\\
76 \VAR{control}\text{ } \OPn{\VAR{arg}}%
77 }{\}})}
79 Unless handled, signal as correctable \kwd{error} \VAR{condition} or
80 a new condition of \VAR{type} or, with \FU{format} \VAR{control} and
81 \VAR{arg}s (see p.\ \pageref{section:Format}),
82 \kwd{simple-error}. In the debugger, use \FU{format} arguments
83 \VAR{continue-control} and \VAR{continue-arg}s to tag the continue
84 option. Return \retval{\NIL}.
87 \IT{(\MC*{IGNORE-ERRORS} \PROGN{\VAR{form}})}
89 Return \retval{values of \VAR{form}s} or, in case of \kwd{error}s,
90 \retval{\NIL} and the \retvalii{condition}.
93 \IT{(\FU*{INVOKE-DEBUGGER} \VAR{condition})}
95 Invoke debugger with \VAR{condition}.
98 \IT{(\MC*{ASSERT} \VAR{test} \OP{(\OPn{\VAR{place}})
99 \Op{%
100 \xorGOO{%
101 \VAR{condition}\text{ } \OPn{\VAR{continue-arg}}\\
102 \VAR{type}\text{ } \Goos{\kwd{:}\VAR{initarg-name} \VAR{value}}\\
103 \VAR{control}\text{ } \OPn{\VAR{arg}}}{\}}}})}
105 If \VAR{test}, which may depend on \VAR{place}s, returns \NIL,
106 signal as correctable \kwd{error} \VAR{condition} or a new condition
107 of \VAR{type} or, with \FU{format} \VAR{control} and \VAR{arg}s (see
108 p.\ \pageref{section:Format}), \kwd{error}. When using the
109 debugger's continue option, \VAR{place}s can be altered before
110 re-evaluation of \VAR{test}. Return \retval{\NIL}.
113 \IT{(\MC*{HANDLER-CASE} \VAR{foo}
114 \OPn{(\VAR{type} (\Op{\VAR{var}})
115 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
116 \PROGN{\VAR{condition-form}})}
117 \Op{(\kwd{:no-error} (\OPn{\VAR{ord-$\lambda$}})
118 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
119 \PROGN{\VAR{form}})})}
121 If, on evaluation of \VAR{foo}, a condition of \VAR{type} is
122 signalled, evaluate matching \VAR{condition-form}s with \VAR{var}
123 bound to the condition, and return \retval{their values}. Without
124 a condition, bind \VAR{ord-$\lambda$}s to values of \VAR{foo} and
125 return \retval{values of \VAR{form}s} or, without a
126 \kwd{:no-error} clause, return \retval{values of \VAR{foo}}. See
127 p.\ \pageref{section:Functions} for (\OPn{\VAR{ord-$\lambda$}}).
130 \IT{(\MC*{HANDLER-BIND} (\OPn{(\VAR{condition-type}
131 \VAR{handler-function})}) \PROGN{\VAR{form}})}
133 Return \retval{values of \VAR{form}s} after evaluating them with
134 \VAR{condition-type}s dynamically bound to their respective
135 \VAR{handler-function}s of argument condition.
138 \IT{(\MC*{WITH-SIMPLE-RESTART} (\xorGOO{\VAR{restart}\\
139 \NIL}{\}} \VAR{control}
140 \OPn{\VAR{arg}}) \PROGN{\VAR{form}})}
142 Return \retval{values of \VAR{form}s} unless \VAR{restart} is called
143 during their evaluation. In this case, describe restart using
144 \FU{format} \VAR{control} and \VAR{arg}s (see
145 p.\ \pageref{section:Format}) and return \retval{\NIL}
146 and \retvalii{\T}.
149 \IT{(\MC*{RESTART-CASE} \VAR{form} \OPn{(\VAR{foo}
150 (\OPn{\VAR{ord-$\lambda$}})
151 \orGOO{\kwd{:interactive} \VAR{ arg-function}\\
152 \kwd{:report } \xorGOO{%
153 \VAR{report-function}\\
154 \VAR{string}\DF{\LIT{"}\VAR{foo}\LIT{"}}}{.}\\
155 \kwd{:test} \VAR{ test-function}\DF{\T}}{\}}
156 \OPn{(\kwd{declare} \OPn{\NEV{\VAR{decl}}})}
157 \PROGN{\VAR{restart-form}})})}
159 Evaluate \VAR{form} with dynamically established restarts
160 \VAR{foo}. Return \retval{values of \VAR{form}} or, if by
161 (\FU{invoke-restart} \VAR{foo} \OPn{\VAR{arg}}) one restart
162 \VAR{foo} is called, use \VAR{string} or \VAR{report-function} (of
163 a stream) to print a description of restart \VAR{foo} and return
164 the \retval{values of its \VAR{restart-form}s}. \VAR{arg-function}
165 supplies appropriate \VAR{arg}s if \VAR{foo} is called by
166 \FU{invoke-restart-interactively}. If (\VAR{test-function}
167 \VAR{condition}) returns \T, \VAR{foo} is made visible under
168 \VAR{condition}. \OPn{\VAR{arg}} matches
169 (\OPn{\VAR{ord-$\lambda$}}); see p.\ \pageref{section:Functions}
170 for the latter.
173 \IT{(\MC*{RESTART-BIND} (\OPn{(\xorGOO{\NEV{\VAR{restart}}\\
174 \NIL}{\}}
175 \VAR{restart-function} \orGOO{\kwd{:interactive-function}
176 \VAR{ function}\\
177 \kwd{:report-function} \VAR{ function}\\
178 \kwd{:test-function} \VAR{ function}}{\}})}) \PROGN{\VAR{form}})}
180 Return \retval{values of \VAR{form}s} evaluated with
181 \VAR{restart}s dynamically bound to \VAR{restart-function}s.
184 \IT{\arrGOO{(\FU*{INVOKE-RESTART} \VAR{ restart} \OPn{\VAR{ arg}})\\
185 (\FU*{INVOKE-RESTART-INTERACTIVELY} \VAR{ restart})}{.}}
187 Call function associated with \VAR{restart} with arguments given or
188 prompted for, respectively. If \VAR{restart} function returns,
189 return \retval{its values}.
192 \IT{(\xorGOO{\FU*{COMPUTE-RESTARTS}\\
193 \FU*{FIND-RESTART} \VAR{ name}}{\}} \Op{\VAR{condition}})}
195 Return list of \retval{all restarts}, or innermost \retval{restart}
196 \VAR{name}, respectively, out of those either associated
197 with \VAR{condition} or un-associated at all; or, without
198 \VAR{condition}, out of all restarts. Return \retval{\NIL} if search
199 is unsuccessful.
202 \IT{(\FU*{RESTART-NAME} \VAR{restart})}
204 \retval{Name of \VAR{restart}}.
207 \IT{(\xorGOO{\FU*{ABORT}\\
208 \FU*{MUFFLE-WARNING}\\
209 \FU*{CONTINUE}\\
210 \FU*{STORE-VALUE} \VAR{ value}\\
211 \FU*{USE-VALUE} \VAR{ value}}{\}} \Op{\VAR{condition}\DF{\NIL}})}
213 Transfer control to innermost applicable restart with same name
214 (i.e. \kwd{abort}, \ldots, \kwd{continue} \ldots) out of those either associated
215 with \VAR{condition} or un-associated at all; or, without
216 \VAR{condition}, out of all restarts. If no restart is found,
217 signal \kwd{control-error} for \FU{abort} and \FU{muffle-warning},
218 or return \retval{\NIL} for the rest.
221 \IT{(\MC*{WITH-CONDITION-RESTARTS} \VAR{condition}
222 \VAR{restarts} \PROGN{\VAR{form}})}
224 Evaluate \VAR{form}s with \VAR{restarts}
225 dynamically associated with \VAR{condition}. Return \retval{values
226 of \VAR{form}s}.
229 \IT{\arrGOO{(\FU*{ARITHMETIC-ERROR-OPERATION} \VAR{ condition})\\
230 (\FU*{ARITHMETIC-ERROR-OPERANDS} \VAR{ condition})}{.}}
232 \retval{List of function} or \retval{of its operands} respectively,
233 used in the operation which caused \VAR{condition}.
236 \IT{(\FU*{CELL-ERROR-NAME} \VAR{condition})}
238 \retval{Name of cell} which caused \VAR{condition}.
241 \IT{(\FU*{UNBOUND-SLOT-INSTANCE} \VAR{condition})}
243 \retval{Instance} with unbound slot which caused \VAR{condition}.
246 \IT{(\FU*{PRINT-NOT-READABLE-OBJECT} \VAR{condition})}
248 The \retval{object} not readably printable under \VAR{condition}.
251 \IT{\arrGOO{%
252 (\FU*{PACKAGE-ERROR-PACKAGE } \VAR{condition})\\
253 (\FU*{FILE-ERROR-PATHNAME } \VAR{condition})\\
254 (\FU*{STREAM-ERROR-STREAM } \VAR{condition})}{.}}
256 \retval{Package}, \retval{path}, or \retval{stream}, respectively,
257 which caused the \VAR{condition} of indicated type.
260 \IT{\arrGOO{(\FU*{TYPE-ERROR-DATUM} \VAR{ condition})\\
261 (\FU*{TYPE-ERROR-EXPECTED-TYPE} \VAR{ condition})}{.}}
263 \retval{Object} which caused \VAR{condition} of type \kwd{type-error}, or its
264 \retval{expected type}, respectively.
267 \IT{\arrGOO{(\FU*{SIMPLE-CONDITION-FORMAT-CONTROL} \VAR{ condition})\\
268 (\FU*{SIMPLE-CONDITION-FORMAT-ARGUMENTS} \VAR{ condition})}{.}}
270 Return \retval{\FU{format} control} or list of \retval{\FU{format}
271 arguments}, respectively, of \VAR{condition}.
274 \IT{\V{\A break-on-signals\A}\DF{\NIL}}
275 {\index{*BREAK-ON-SIGNALS*@\A BREAK-ON-SIGNALS\A}
276 Condition type debugger is to be invoked on.
279 \IT{\V{\A debugger-hook\A}\DF{\NIL}}
280 {\index{*DEBUGGER-HOOK*@\A DEBUGGER-HOOK\A}
281 Function of condition and
282 function itself. Called before debugger.
285 \end{LIST}
288 %%% Local Variables:
289 %%% mode: latex
290 %%% TeX-master: "clqr"
291 %%% End: