[plt-scheme] restart exception handling?

From: David Vanderson (david.vanderson at gmail.com)
Date: Sun Jul 13 20:49:30 EDT 2008

Matthew Flatt wrote:
> At Sun, 13 Jul 2008 15:22:23 -0400, David Vanderson wrote:
>> Is there a reason why each exception should be thrown in tail position 
>> with respect to the function?  Is that the convention for continuable 
>> exceptions?
> My intent was to set up some reasonable continuation for the exception
> handler (i.e., the continuation of the call to functions like
> `raise-continuable-type-error').
> As above, I imagined that the exception handler would continue by
> supplying some result for the call to `mega-fun'. Another choice would
> be
>    (define (mega-fun x y z)
>      (let ([x (if (not (integer? x))
>                   (raise-continuable-type-error 'mega-fun "integer" x)
>                   x)])
>        (let ([y (if (not (list? y)) ....)])
>          ....)))
> in which case the exception handler could supply an alternate value for
> the argument. The exception raiser and exception handler would have to
> agree on some protocol.
>> Could you please elaborate on why you couldn't (or shouldn't) just 
>> replace "raise-type-error" with "raise-continuable-type-error"?
> What continuation would an exception handler be able to resume in that
> case?

Your example shows me where I was going wrong.  Simply replacing the 
raise call wouldn't do anything with the value passed to the 
continuation.  So simply resuming the continuation of "unless" can't 
change the computation of "mega-fun".

Thanks for enlightening me.

Posted on the users mailing list.