Re: [Scheme-reports] 4.2.7. Exception Handling
Alaric Snell-Pym 18 May 2011 10:19 UTC
On 05/18/11 09:32, Andy Wingo wrote:
> Hi!
>
> The docs for `guard' note that if no cond clause matches, that the
> exception is re-raised:
>
> "then `raise' is re-invoked on the raised object within the dynamic
> extent of the original call to `raise' except that the current
> exception handler is that of the `guard' expression."
>
> But it also notes that the exception handler's continuation and dynamic
> context are that of the guard expression.
>
> What does it mean to specify that the object is re-raised from the
> original `raise' dynamic context? AFAICS there is no way to know what
> the dynamic context is at the time of `raise', as the dynamic state is
> unwound before invoking the handler.
The dynamic state isn't unwound. The handler is, in effect, a closure
shoved into a parameter that is invoked by RAISE - in its dynamic state.
It may then choose to unwind by leaping back to an outer continuation
kept near where GUARD happened. Or it may choose to "retry" by unwinding
to a continuation somewhere within the GUARD. Or something else...
>
> Here's a program:
>
> (define p (make-parameter 0))
> (define f
> (lambda ()
> (guard (e ((p)))
> (parameterize ((p (+ (p) 1)))
> (raise #t)))))
>
> What should `(f)' evaluate to, 0 or 1?
1, I believe! I don't have the draft in front of me to check the text,
though. So don't laugh at me if I'm stupid and wrong.
> Andy
ABS
--
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports