bind_expression: bind `(' handlers `)' expression ; handlers: handler [`;' handlers] ;
A bind_expression
sets one or more handlers for any conditions which
are raised or signaled during the evaluation of the expression
.
The value returned from the bind
is the value returned by the
expression
.
handler: `(' condition `,' expression `)' ; condition: expression ;
Each handler
is an expression
which will be invoked if the
condition
, or a sub condition thereof, is raised (or signaled).
The condition
normally is an instance of tom.Condition
.
Implicitly declared in the context of the handler expression
is a
local variable Condition condition
; it is the condition being
raised.
A useful thing to do for a handler is to perform a throw
to force
a non-local exit out of the exceptional state. Note, however, that the
handler is invoked in the context of the condition raiser. This implies
that in the following expression
catch (self) bind ((error, {[self throw void]; nil;})) { do_something_difficult; }
the throw
need not immediately return from this catch
since another catch of the same object self
could have been set
(and active) during the invocation of do_something_difficult
.
A handler does not need to handle the condition by performing a
non-local exit. If the handler does not wish to handle it, the value
returned by the handler should be the condition
object it was
passed. If the handler returns any other value, which must always be an
object, the handler considers the condition to have been handled. If
the
condition was signaled, the value returned by the handler is returned
from the signal
.
If the condition was raised, the return value is ignored and the
condition mechanism continues as if the handler had not handled the
condition.
Go to the first, previous, next, last section, table of contents.