[R6RS] Semantics of `raise'

William D Clinger will at ccs.neu.edu
Mon Mar 6 06:36:40 EST 2006


Mike wrote:
> (raise obj)
>
>   Invokes the current exception handler on obj. The handler is called
>   in the dynamic environment of the call to raise, except that the
>   current exception handler is that in place for the call to
>   with-exception-handler that installed the handler being called. The
>   handler's continuation is otherwise unspecified.
>
> From earlier discussions long ago, I remember that my impression was
> that you (Will, that is) would like something like `raise' and
> `with-exception-handler', but with a tightened-up specification of
> `raise', that might go as follows:
>
> (raise obj)
>
>   Invokes the current exception handler on obj. The handler is called
>   with a continuation that is equivalent to the continuation of the
>   call to `raise', except for the current exception handler of its
>   dynamic environment, which is that in place for the call to
>   `with-exception-handler' that installed the handler being called.
>
> Is that impression correct?

Not quite, although it is conceivable that I have argued
for that second description of raise in the past.  What
I really want is to have two distinct procedures:

(raise-continuable obj)

   Invokes the current exception handler on obj. The handler is called
   in the dynamic environment and continuation of the call to
   raise-continuable.

(raise-non-continuable obj)

   Invokes the current exception handler on obj. The handler is called
   in the dynamic environment of the call to raise, except that the
   current exception handler is the one that was in place for the call
   to with-exception-handler that installed the handler being called,
   *and* the continuation will raise a non-continuable
   &tried-to-continue-from-a-non-continuable-exception exception
   if the exception handler returns instead of going into an
   infinite loop or calling an escape procedure.

For the R6RS, I think raise should have the
raise-non-continuable semantics (which you might want to
rephrase a bit), while allowing implementors to add
raise-continuable as an extension.  The raise-continuable
procedure is dangerous in the sense that it can be used
to write an infinite loop that repeatedly raises a
&tried-to-continue-from-a-non-continuable-exception
exception, and a surprising number of Scheme programmers
have said they do not want to be trusted with the power
to write infinite loops in Scheme.

Will



More information about the R6RS mailing list