[prev in list] [next in list] [prev in thread] [next in thread] 

List:       racket-users
Subject:    [plt-scheme] call-with-exception-handler inside with-handlers
From:       mflatt () cs ! utah ! edu (Matthew Flatt)
Date:       2007-12-22 0:58:54
Message-ID: 20071222005855.6E3CF6500C9 () mail-svr1 ! cs ! utah ! edu
[Download RAW message or body]

At Fri, 21 Dec 2007 17:51:42 -0700, Matthew Flatt wrote:
> At Fri, 21 Dec 2007 21:29:15 +0100, "Marco Maggi" wrote:
> > why the form:
> > 
> > (with-handlers (((lambda (o)
> >                    #t) (lambda (exn)
> >                          (list 'out exn))))
> >   (call-with-exception-handler
> >       (lambda (exn)
> >         (list 'error exn))
> >     (lambda ()
> >       (raise 123))))
> > 
> > gives  me an  uncaught exception  "(error 123)"  rather than
> > simply returning the value  "(out 123)"?  If the explanation
> > involves continuations, continuation  marks or prompts: just
> > tell me to forget it (I don't wanna know :-).
> 
> Both `with-handlers' and `call-with-exception-handler' evaluate the
> body expression/thunk in tail position with respect to setting the
> exception. So, the `call-with-exception-handler' is overwriting the
> handler installed by `with-handlers'.

Sorry for the self-reply, but after further thought, this looks like a
"security hole". It provides a way to escape from the `with-handlers'
expression that the person who wrote `with-handlers' is unlikely to
have considered.

So, this seems like a reason to take away the more primitive behavior
after all.

Matthew



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic