emacs.d/clones/lisp/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node327.html

70 lines
4.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>29.3.12. Serious Conditions</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Serious Conditions">
<meta name="keywords" value="clm">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<b>Common Lisp the Language, 2nd Edition</b>
<BR> <HR><A NAME=tex2html5779 HREF="node328.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html5777 HREF="node315.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html5771 HREF="node326.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html5781 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html5782 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html5780 HREF="node328.html"> Non-Serious Conditions</A>
<B>Up:</B> <A NAME=tex2html5778 HREF="node315.html"> Survey of Concepts</A>
<B> Previous:</B> <A NAME=tex2html5772 HREF="node326.html"> Interactive Condition Handling</A>
<HR> <P>
<H2><A NAME=SECTION0033312000000000000000>29.3.12. Serious Conditions</A></H2>
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
The <tt>ignore-errors</tt> macro will trap conditions of type <tt>error</tt>. There are,
however, conditions that are not of type <tt>error</tt>.
<P>
Some conditions are not considered errors but are still very serious, so
we call them <i>serious conditions</i> and we use the type <tt>serious-condition</tt> to
represent them. Conditions such as those that might be signaled for
``stack overflow'' or ``storage exhausted'' are in this category.
<P>
The type <tt>error</tt> is a subtype of <tt>serious-condition</tt>, and it would technically
be correct to use the term ``serious condition'' to refer to all serious
conditions whether errors or not. However, normally we use the term
``serious condition'' to refer to things of type <tt>serious-condition</tt> but not
of type <tt>error</tt>.
<P>
The point of the distinction between errors and other serious conditions
is that some conditions are known to occur for reasons that are beyond the
scope of Common Lisp to specify clearly. For example, we know that a stack
will generally be used to implement function calling, and we know that stacks
tend to be of finite size and are prone to overflow. Since the available
stack size may vary from implementation to implementation, from session
to session, or from function call to function call, it would be confusing
to have expressions such as <tt>(ignore-errors (+ a b))</tt> return a number sometimes
and <tt>nil</tt> other times if <tt>a</tt> and <tt>b</tt> were always bound to numbers and the stack
just happened to overflow on a particular call. For this reason, only
conditions of type <tt>error</tt> and not all conditions of type <tt>serious-condition</tt>
are trapped by <tt>ignore-errors</tt>. To trap other conditions, a lower-level
facility must be used (such as <tt>handler-bind</tt> or <tt>handler-case</tt>).
<P>
By convention, the function <tt>error</tt> is preferred over <tt>signal</tt> to signal conditions
of type <tt>serious-condition</tt> (including those of type <tt>error</tt>). It is the use of
the function <tt>error</tt>, and not the type of the condition being signaled, that
actually causes the debugger to be entered.
<P>
<hr>
<b>Compatibility note:</b> The Common Lisp Condition System differs from that of Zetalisp in this respect.
In Zetalisp the debugger is entered for an unhandled signal if the <tt>error</tt>
function is used <i>or</i> if the condition is of type <tt>error</tt>.
<hr>
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<BR> <HR><A NAME=tex2html5779 HREF="node328.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html5777 HREF="node315.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html5771 HREF="node326.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html5781 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html5782 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html5780 HREF="node328.html"> Non-Serious Conditions</A>
<B>Up:</B> <A NAME=tex2html5778 HREF="node315.html"> Survey of Concepts</A>
<B> Previous:</B> <A NAME=tex2html5772 HREF="node326.html"> Interactive Condition Handling</A>
<HR> <P>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>