[PRL] compiling `return'

Joe Marshall jrm at ccs.neu.edu
Mon Jun 27 12:13:19 EDT 2005


Dave Herman <dherman at ccs.neu.edu> writes:

> If you're compiling an imperative language with `return' into Scheme,
> is the easiest implementation of tail call elimination to capture an
> escape continuation (or raise an exception) that expects a thunk and
> then apply the thunk in tail position? E.g.:
>
>      [[ proc(x1 .. xn) { ... return e; ... } ]]
>    = (lambda (x1 .. xn)
>        (let ([thunk (let/ec return
>                       ...
>                       (return (lambda () [[ e ]]))
>                       ...)])
>          (thunk)))
>
> Is this a trampoline?

Yes, in a bizarre way.




More information about the PRL mailing list