[racket] raise vs abort
On Thu, Jan 6, 2011 at 6:32 AM, Keiko Nakata <keiko at kurims.kyoto-u.ac.jp> wrote:
>> 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.
>
> Something along this:
>
> (with-handlers ([(lambda (_) true) (lambda (x) ((car x) (cdr x)))])
> (prompt (+ (control f (raise (cons f 3))) 1)))
>
> will not work?
>
Now I'm not sure I understand what you're trying to do. I thought the
goal was to simulate `raise' using `abort', but this program uses
`raise' directly.
>> (with a prompt handler that calls the continuation handler),
>
> What is a difference between 'prompt handler' and 'continuation handler'?
>
Sorry, I meant exception handler, not continuation handler.
>> I don't think `raise' can be defined via `abort'.
>
> This is something I want to understand, as it is often
> said that 'raise' is implementable via 'abort'. I mean,
> I want to see how Racket diverges from these conventional view
> and, more importantly, why.
>
I'm not the right person to say why (and I may even be wrong about the
what), but here are two programs that I think exhibit obstacles to
implementing `raise' via `abort'.
The first program installs a continuation barrier between the frame in
which the exception handler is installed and the frame from which
`raise' is called. I'm using continuation marks so that the exception
handler can observer whether it's called with the right continuation.
(call-with-exception-handler
(λ (exn)
(displayln (continuation-mark-set->list (current-continuation-marks) 1))
(abort (void)))
(λ ()
(with-continuation-mark 1 'a
(call-with-continuation-barrier
(λ () (raise 3))))))
The second program places a `dynamic-wind' between the handler
installation and the `raise'.
(call-with-exception-handler
(λ (exn)
(displayln (continuation-mark-set->list (current-continuation-marks) 1))
(abort (void)))
(λ ()
(with-continuation-mark 1 'a
(dynamic-wind
(λ () (displayln "enter"))
(λ () (raise 3))
(λ () (displayln "exit"))))))