Next: iklib syntaxes integrable, Previous: iklib syntaxes blocking, Up: iklib syntaxes [Index]
Install and return a thunk that, wherever it is called, evaluates ?thunk in the dynamic environment of the macro use and returns its return values. If ?thunk raises an exception: apply the procedure ?exception-retvals-maker to the raised object and return its return values.
Exceptions raised by ?exception-retvals-maker are not blocked.
Usage examples:
(import (vicare) (only (vicare checks) with-result add-result)) (define parm (make-parameter #f)) (with-result (parametrise ((parm 'outer)) (let* ((counter 0) (thunk (parametrise ((parm 'inner)) (with-current-dynamic-environment values (lambda () (set! counter (+ 1 counter)) (add-result (list 'inside-thunk (parm)))))))) (add-result (parm)) (add-result 'calling-thunk-1) (thunk) (add-result 'calling-thunk-2) (thunk) counter))) ⇒ (2 (outer calling-thunk-1 (inside-thunk inner) calling-thunk-2 (inside-thunk inner))) (with-result (parametrise ((parm 'outer)) (let* ((counter 0) (thunk (parametrise ((parm 'inner)) (with-current-dynamic-environment values (lambda () (set! counter (+ 1 counter)) (add-result (list 'inside-thunk (parm))) (add-result 'raise-exception) (raise 123)))))) (add-result (parm)) (add-result 'calling-thunk-1) (thunk) (add-result 'calling-thunk-2) (thunk) counter))) ⇒ (2 (outer calling-thunk-1 (inside-thunk inner) raise-exception calling-thunk-2 (inside-thunk inner) raise-exception))