Next: unwind except 1, Previous: unwind syntaxes, Up: unwind [Contents][Index]
The concept of dynamic extent termination is defined by MMCK Exceptional Conditions’s unwind–protection mechanism and it is not a standard Scheme concept. In this discussion, we consider the syntax use:
(with-unwind-handler ?unwind-handler ?thunk)
the procedure ?unwind-handler is called when the dynamic extent of the invocation of
?thunk terminates; dynamic extent termination is different from dynamic extent
exiting as determined by dynamic-wind
. When the execution flow exits the dynamic
extent of a function call: such extent might also terminate, but not all the exits are also
terminations.
The dynamic extent of a call to ?thunk is terminated, and so ?unwind-handler is invoked, when:
guard
, but only when a clause of guard
has a test expression returning non–false.
(guard (E (?test ?expr)) (with-unwind-handler ?unwind-handler ?thunk))
This is what happens:
guard
and it returns non–false.
with-unwind-handler
, and its return values discarded.
guard
and
its return values are returned to the continuation of guard
.
return
, as defined by the library (mmck
exceptional-condition)
, to escape from a form that encloses an unwind–protection syntax.
?unwind-handler is applied to the symbol ‘escape’.
As bound by the returnable
: the syntax return
reinstates a continuation at the
beginning or outside of returnable
and performs special operations to terminate the dynamic
extent of the call to ?thunk in an unwind–protection form.
The dynamic extent of a call to ?thunk is not terminated, and so ?unwind-handler is not invoked, when:
raise-continuable
, and such call
performs a normal return to ?thunk.
exit
).
About the termination of the dynamic extent of ?thunk, we must acknowledge that:
&non-reinstatable
component (see &non-reinstatable).
guard
intercepts it: if a test
expression in a clause of guard
raises an exception, the ?unwind-handler may not be
called.
While it is possible to raise
any object: it is better to always raise a condition object
(possibly compound), so that the test expressions in guard
uses can just be condition
object type predicates; such predicates never raise exceptions.
If ?unwind-handler raises an exception: such exception is blocked and discarded.
Next: unwind except 1, Previous: unwind syntaxes, Up: unwind [Contents][Index]
This document describes version 0.1.0-devel.1 of MMCK Exceptional Conditions.