[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] 4.2.7. Exception Handling
- To: scheme-reports@x
- Subject: Re: [Scheme-reports] 4.2.7. Exception Handling
- From: Alaric Snell-Pym <alaric@x>
- Date: Wed, 18 May 2011 11:19:02 +0100
- In-reply-to: <email@example.com>
- References: <firstname.lastname@example.org>
On 05/18/11 09:32, Andy Wingo wrote:
> 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.
Scheme-reports mailing list