by Dave Herman (dherman at ccs dot neu dot edu)
This library provides utilities for tail recursion.
|(require (planet dherman/tail:4:0))|
|(trace-begin body-expr ...+)|
The identifier k-id is bound to a special form that invokes the captured continuation in tail position with respect to the entire let/tc expression.
|> (down 10)|
(0 1 2 3 4 5 6 7 8 9 10)
|> (down* 10)|
To achieve proper tail recursion, the argument to k-id is evaluated in the hole of the captured continuation, i.e., after abandoning the current continuation. Note that this behavior is significant when the argument expression performs side effects.
The captured continuation k-id can only be applied to exactly one argument. (If control returns normally, i.e., without explicitly invoking k-id, it may return any number of values.)
eval:11:0: k: bad syntax in: (k 1 2 3)
|(with-continuation-mark* key-expr val-expr update-expr body-expr ...+)|