[racket] continuation barrier in raise

From: Casey Klein (clklein at eecs.northwestern.edu)
Date: Wed Jan 5 09:32:09 EST 2011

On Wed, Jan 5, 2011 at 7:40 AM, Keiko Nakata <keiko at kurims.kyoto-u.ac.jp> wrote:
> Thanks for the code.
>
> I'm a bit confused as replacing 'call-with-exception-handler' by
> 'with-handlers' seem to not produce the same bahavior:
>
> (call-with-continuation-prompt
>  (lambda ()
>  (with-handlers
>   ([(lambda (_) true) (lambda (_)
>     (call-with-current-continuation
>      (lambda (k) (abort-current-continuation t k))
>      t))])
>   (lambda () (raise 3))))
>  t
>  (lambda (k)
>  (call-with-continuation-prompt
>   (lambda () (k 4))
>   t)))
>
> What am I missing?
>

A `with-handlers' handler and a `call-with-exception-handler' handler
are invoked with different continuations. A `with-handlers' handler is
invoked with the continuation of the entire `with-handlers'
expression; a `call-with-exception-handler' handler is invoked with
the continuation of the `raise' call. In this example, the barrier is
gone by the time the `with-handlers' handler runs.

I only discovered this subtlety myself about a week ago, but somehow
it didn't occur to me that you were missing it until after I sent my
message. By the time I made it back to a computer to follow up, you'd
already asked the follow up question :)


Posted on the users mailing list.