Previous: iklib compensations usage, Up: iklib compensations [Index]
The compensations mechanism is built on top of the unwind protection mechanism:
Allocate a new compensations stack, then evaluate all the ?body
forms in the given order. If no error occurs: call
run-compensations
, reset the compensations stack to empty,
finally return the result value of the last ?body form.
If the dynamic extent of the evaluation of the ?body forms is terminated: the accumulated compensations are evaluated in reverse order.
Allocate a new compensations stack, then evaluate all the ?body forms in the given order. If no error occurs: reset the compensations stack to empty, return the result value of the last ?body form.
If the dynamic extent of the evaluation of the ?body forms is terminated by escaping from the body directly or by escaping from the body while handling a raised a exception: the accumulated compensations are evaluated in reverse order.
Evaluate all the compensation thunks in the current stack, in last in/first out order; compensation thunks are called in the current dynamic environment. If a compensation thunk raises an exception: the exception is blocked and silently discarded.
This function should be called only inside the dynamic environment
prepared by with-compensations
and similar syntaxes. It can be
called multiple times: every time the compensation thunks are consumed
and removed from the stack.
First push ?release-thunk on the current compensations stack, then evaluate ?alloc-thunk. Return the results of evaluating ?alloc-thunk.
First evaluate all the ?alloc expressions then, only if they perform a normal return: push one thunk holding all the ?release forms on the current compensations stack. Return the result of the last ?alloc expression.
While expanding the ?release forms: the fluid syntax <>
is bound to an identifier referencing the object returned by the
?alloc forms; this allows to code:
(define (make-compensated-object) (compensate (make-new-object) (with (destroy-object <>))))
rather than:
(define (make-compensated-object) (receive-and-return (obj) (compensate (make-new-object) (with (destroy-object obj)))))
Push a thunk holding the ?release forms on the current compensations stack.
Push the given thunk on the current compensations stack.
Previous: iklib compensations usage, Up: iklib compensations [Index]