Common Lisp the Language, 2nd Edition
Next: Survey of Concepts
Up: Conditions
Previous: Introduction
In this section, we introduce changes to the terminology defined in
section 1.2.4.
A condition is an interesting situation in a program that has been detected and announced. Later we allow this term also to refer to objects that programs use to represent such situations.
An error is a condition in which normal program execution may not continue without some form of intervention (either interactively by the user or under some sort of program control, as described below).
The process by which a condition is formally announced by a program
is called signaling. The function signal
is the
primitive mechanism by which such announcement is done. Other
abstractions, such as error
and cerror
, are
built using signal
.
The first edition is ambiguous about the reason why a particular program action ``is an error.’’ There are two principal reasons why an action may be an error without being required to signal an error:
Detecting the error might be prohibitively expensive.
For example, (+ nil 3)
is an error. It is likely that
the designers of Common Lisp believed this would be an error in all
implementations but felt it might be excessively expensive to detect the
problem in compiled code on stock hardware, so they did not require that
it signal an error.
Some implementations might implement the behavior as an extension.
For example, (loop for x from 1 to 3 do (print x))
is an
error because loop
is not defined to take atoms in its
body. In fact, however, some implementations offer an extension that
makes this well-defined. In order to leave room for such extensions, the
first edition used the ``is an error’’ terminology to keep implementors
from being forced to signal an error in the extended
implementations.
[This example was written well before the vote by X3J13 in January 1989 to add exactly this extension to the forthcoming draft standard (see chapter 26).-GLS]
In this chapter, we use the following terminology. [Compare this to the terminology presented in section 28.1.1.-GLS]
foo
has no side effects and undefined value, the expression
(length (list (foo)))
is completely well defined even for
portable code. However, the effect of (print (list (foo)))
is not well defined.
Next: Survey of Concepts
Up: Conditions
Previous: Introduction
AI.Repository@cs.cmu.edu