[racket] raise vs abort
On Wed, Jan 5, 2011 at 8:22 AM, Keiko Nakata <keiko at kurims.kyoto-u.ac.jp> wrote:
>> raise just calls a handler that is the one that does the interesting
>> control.
>
> So having separate implementations is for optimization?
>
I don't think `raise' can be defined via `abort'. `raise' calls the
exception handler in the current continuation. If the exception
handler were installed as a continuation prompt (with a prompt handler
that calls the continuation handler), `raise' could transfer control
to the exception handler via `abort', but the exception handler's
continuation would be wrong. I don't think you could rebuild the
missing portion of the continuation by reinstalling it before calling
the exception handler due to dynamic-wind frames, which could notice
the exit and re-entry, and continuation barriers, which could prevent
reinstallation.
(Exception handlers are actually installed as continuation marks, with
`raise' collecting the marks and trying them inside-out. I imagine
that `raise' is implemented in C because many other C-implemented
primitives need to call it, but that's just a guess.)