Common Lisp the Language, 2nd Edition


next up previous contents index
Next: Anonymous Restarts Up: Survey of Concepts Previous: Object-Oriented Basis of

29.3.5. Restarts

change_begin
In older Lisp dialects (such as MacLisp), an attempt to signal an error of a given type often carried with it an implicit promise to support the standard recovery strategy for that type of error. If the signaler knew the type of error but for whatever reason was unable to deal with the standard recovery strategy for that kind of error, it was necessary to signal an untyped error (for which there was no defined recovery strategy). This sometimes led to confusion when people signaled typed errors without realizing the full implications of having done so, but more often than not it meant that users simply avoided typed errors altogether.

The Common Lisp Condition System, which is modeled after the Zetalisp condition system, corrects this troublesome aspect of previous Lisp dialects by creating a clear separation between the act of signaling an error of a particular type and the act of saying that a particular way of recovery is appropriate. In the divide example above, simply signaling an error does not imply a willingness on the part of the signaler to cooperate in any corrective action. For example, the following sample interaction illustrates that the only recovery action offered for this error is ``Return to Lisp Toplevel'':

Lisp> (+ (divide 3 0) 7) 
Error: Attempt to divide 3 by 0. 
To continue, type :CONTINUE followed by an option number: 
 1: Return to Lisp Toplevel. 
Debug> :continue 1 
Returned to Lisp Toplevel. 
Lisp>

When an error is detected and the function error is called, execution cannot continue normally because error will not directly return. Control can be transferred to other points in the program, however, by means of specially established ``restarts.''
change_end



next up previous contents index
Next: Anonymous Restarts Up: Survey of Concepts Previous: Object-Oriented Basis of


AI.Repository@cs.cmu.edu