[plt-scheme] restart exception handling?

From: YC (yinso.chen at gmail.com)
Date: Fri Jul 11 17:18:21 EDT 2008

On Fri, Jul 11, 2008 at 6:21 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> Not in general. Aside from `exn:break', built-in exceptions are raised
> in a non-continuable way.

Just curious - what are the main reasons behind the exception design to make
them non-continuable by default?  Is it due to performance or that
continuations shouldn't be used at low level exceptions?  (is contination
the basis for flow controls as scheme generally advertises?)

In this specific case, you could adjust the compilation of top-level
> variable access by defining `#%top'. Here's one way:
>  > (define (handle-undefined exn)
>     (abort-current-continuation
>      (default-continuation-prompt-tag)
>      (lambda () (letrec ([x x]) x))))
>  > (require (only-in scheme/base [#%top orig-top]))
>  > (define-syntax-rule (#%top . id)
>    (call-with-continuation-prompt
>     (lambda ()
>       (call-with-exception-handler
>        (orig-top . handle-undefined)
>        (lambda () (orig-top . id))))))
>  > undef
>  made-up
>  > (define def 5)
>  > def
>  5
> Installing a prompt and exception handler for every top-level lookup is
> expensive, though --- about 50 times as expensive as a normal top-level
> lookup (when the variable is defined) in my test.

This is an interesting technique - thanks for sharing.  The cost is
certainly a concern if every lookup pays for it.

That's not quite the problem. It's more that the exception handler is
> required to escape, and also that the exception for an undefined
> variable doesn't provide a place to escape back to.

So what are the contination-marks used for?  I thought they can be used for
invoking continuations.  The related concepts (prompts, continuation,
escape, etc) continues to escape me even with the manual.  If there are some
links or pointers on how they are all related and used - it's much

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080711/3dc5491a/attachment.html>

Posted on the users mailing list.