resumable evaluates an expression in a context that can intercept named
resumptions.
Syntax
(resumable ⟨expr⟩
((⟨resumption-ctor⟩ ⟨pattern⟩ ...) ⟨handler-body⟩ ...))
Semantics
- The first subform is the expression that may invoke
resume-to. - Each branch must match a resumption constructor, not an arbitrary pattern.
- Patterns on constructor fields are tried in order. If no branch matches the value, it is offered to an enclosing handler for the same resumption. A resumption with no matching handler signals an error.
- When a matching resumption is signaled, control transfers to the handler body.
- The result type of each handler must agree with the result type of the whole
resumableexpression.
Example
(define (make-breakfast-with egg)
(resumable (Some (cook (crack egg)))
((SkipEgg) None)
((ServeRaw _) (Some egg))))