Next: , Previous: , Up: iklib syntaxes   [Index]


6.8.18 Delimited continuations

Syntax: reset ?body

Sets the limit for the delimited continuation and evaluate the expression ?body.

Syntax: shift ?var ?body

Capture the current continuation up to the innermost reset syntax use. The escape function of the delimited continuation is bound to ?var, the the expression ?body is evaluated.

Examples:

(+ 1 (reset 2))
⇒ 3

(reset (* 2 (shift K (K 3))))
⇒ 6

(+ 1 (reset (* 2 (shift K (K 3)))))
⇒ 7

(reset (* 2 (shift K (K (K 2)))))
⇒ 8

(reset (* 2 (shift K (K (K (K 2))))))
⇒ 16