[plt-scheme] 359.3

From: Lauri Alanko (la at iki.fi)
Date: Fri Jan 5 03:56:51 EST 2007

On Thu, Jan 04, 2007 at 08:28:23PM +0800, Matthew Flatt wrote:
>  (call-with-exception-handler
>   (lambda (exn) (+ exn 30))
>   (lambda ()
>    (call-with-exception-handler 
>     (lambda (exn) (+ exn 3))
>     (lambda () (raise 10)))))
>  ; => uncaught exception: 13
> 
>  (call-with-exception-handler
>   (lambda (exn) (+ exn 30))
>   (lambda ()
>    (list (call-with-exception-handler 
>           (lambda (exn) (+ exn 3))
>           (lambda () (raise 10))))))
>  ; => uncaught exception: 43

Is this really a good idea? To my mind, a tail position should only be
magical with respect to its space usage, not other observable behavior.

Granted, the same thing happens with continuation marks, but at least
continuation marks aren't implicitly composed together like the
exception handler is. And when one only accesses the topmost mark, the
tail calls aren't distinguishable.

So, if the exception handlers really are to be chained together, then
I think it should be done _always_. This of course means that the body
thunk cannot and should not be called in a tail position.


Lauri


Posted on the users mailing list.