On Sun, Dec 23, 2012 at 6:55 AM, Per Bothner <[email protected]> wrote:

> Is the following a correct translation of this guard clause:
>
> (guard (var cond-clause ....) body)
>
> First assume there is an else clause:
>
> (call/cc (k)
>    (with-exception-handler
>      (lambda (var)
>        (k (cond cond-clause ...)))
>      (lambda () body)))
>
> If there is no else clause:
>
> (call/cc (k)
>    (with-exception-handler
>      (lambda (var)
>        (k (cond cond-clause ... (else (raise-continuable var)))))
>      (lambda () body)))
>

It's actually more complicated than that, because
in the final (else (raise-continuable var)) case, the
continuation has to be raised from the original
exception handler.

The trick used in the R6RS reference implementation[1]
(which Chibi uses) is to return a thunk and apply it outside
the with-exception-handler.

[1] http://www.r6rs.org/refimpl/r6rs-exceptions.tar.gz

-- 
Alex
_______________________________________________
Scheme-reports mailing list
[email protected]
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

Reply via email to