condition. The condition system was influenced by the Common Lisp error system [? ] and the Standard ML exception mechanism. It is a simplification of the former and an extension of the latter. Following standard practice, this text defines the actions of functions in terms of their normal behaviour. Where an exceptional behaviour might arise, this has been defined in terms of a condition. However, not all exceptional situations are errors. Following Pitman, we use condition to be a kind of occasion in a program when an exceptional situation has been signalled. An error is a kind of condition|error and condition are also used as terms for the objects that represent exceptional situations. A condition can be signalled continuably by passing a continuation for the resumption to signal. If a continuation is not supplied then the condition cannot be continued. These two categories are characterized as follows:
defcondition(see Section ). The definition of a condition causes the creation of a new class of condition. A condition is signalled using the function
signal, which has two required arguments and one optional argument: an instance of a condition, a resume continuation or the empty list, the latter signifying a non-continuable signal, and a thread. A condition can be handled using the special form
with-handler, which takes a function, the handler function, and a sequence of forms to be protected. The initial condition class hierarchy is as follows:
(), the superclass is taken to be
<condition>. Otherwise superclass-name must be
<condition>or the name of one of its subclasses.
call-next-methodto carry out initialization specified by superclasses then does the condition specific initialization.
signalif the given condition is not an instance of the condition class
signal, otherwise, thread indicates the thread on which condition is to be signalled.
signalcalls the nearest enclosing handler with condition. If the second argument is supplied,
signalregisters the specified condition to be signalled on thread. The condition must be an instance of the condition class
<thread-condition>, otherwise an error is signalled (condition class:
<wrong-condition-class>) on the thread calling
signalon a determined thread has no effect on either the signalled or signalling thread except in the case of the above error.
call-next-handlerspecial form calls the next enclosing handler. It is an error to evaluate this form other than within an established handler function. The
call-next-handlerspecial form is normally used when a handler function does not know how to deal with the class of condition. However, it may also be used to combine handler function behaviour in a similar but orthogonal way to
call-next-method(assuming a generic handler function).
signalas its first argument. The resume continuation is the continuation (or
()) that was given to
signalas its second argument.
with-handlerform is evaluated in three steps:
with-handler. The exceptional behaviour of
with-handlerhappens when there is a call to
signalduring the evaluation of protected-form.
signalcalls the nearest enclosing handler-function passing on the first two arguments given to
signal. The handler-function is executed in the dynamic extent of the call to
signal. However, any calls to
signals occurring during the execution of handler-function are dealt with by the nearest enclosing handler outside the extent of the form which established handler-function. It is an error if there is no enclosing handler. In this circumstance the identified error is delivered to the configuration to be dealt with in an implementation-defined way. Errors arising in the dynamic extent of the handler function are signalled in the dynamic extent of the original
signalbut are handled in the enclosing dynamic extent of the handler.
signalreturns with the result passed back from the handler function.