[plt-scheme] exception-handler prompt

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Nov 13 16:02:57 EST 2006

At Mon, 13 Nov 2006 10:47:43 -0500, Dave Herman wrote:
> I'm pretty sure it's never been possible to set the 
> current-exception-handler mutably at top level and use it without at 
> least one surrounding with-handlers. 

Until recently, I don't think it has ever worked to use the exception
handler outside the dynamic extent of the creating `with-handlers',
since the handler previously used `call/ec'.

> If I'm reading the error message 
> correctly, in 359.x this manifests as a "missing prompt" error:
> [...]
> exception raised by exception handler: abort-current-continuation: 
> continuation includes no prompt with the given tag: 
> #<continuation-prompt-tag>; original raise called (with non-exception 
> value): boo!
> What is the rationale behind not having an implicit, top-level prompt 
> for exception handlers?

I think you probably noticed that the following works, but it's a
change from the old behavior, and I did not intend the change:

  (define f (with-handlers ([symbol? (lambda (x) 42)])
   (with-handlers ([void void])
     (current-exception-handler f)
     (raise 'boo!))
   ; => 42, instead of an exception raised by the exception handler

As you suggest, this works because there's a single prompt tag for all
`with-handlers' exception handlers. It's possible that this is a better
exception system, and it would be even better to insert (or simulate) a
default prompt for every initial continuation.

But I'm not sure that it's better, and I'm surprised by the change. For
v360, I'll fix MzScheme to get the old behavior back, and we can
revisit the question after the release.

The new error message will be

 exception raised by exception handler: with-handlers: exception
 handler used out of context; original raise called (with non-exception
 value): boo!

It's implemented by creating a fresh prompt tag for every
`with-handlers' evaluation, and then explicitly using
`continuation-prompt-available?'. Creating a fresh prompt tag is
analogous to the old implementation creating a fresh escape
continuation for each `with-handlers' evaluation.


Posted on the users mailing list.