Discussion:
[Larceny-users] ERR5RS Error Conditions
Ray Racine
2008-02-19 05:10:33 UTC
Permalink
What is the ERR5RS behavior of the following code snippet?
ie, should I have expected to have caught the exception??
(import (rnrs))
(define die (lambda () (vector-ref '#(1 2) 3)))
(with-exception-handler (lambda (h) #t) (lambda () (die)))
Error: vector-ref: 3 is not a valid index into vector
Entering debugger; type "?" for help.
debug> #<EOF>
William D Clinger
2008-02-23 04:35:02 UTC
Permalink
Post by Ray Racine
What is the ERR5RS behavior of the following code snippet?
ERR5RS does not specify the R6RS exception semantics,
so the behavior of that code snippet is officially
unspecified.
Post by Ray Racine
ie, should I have expected to have caught the exception??
Yes. For Larceny's ERR5RS mode, I tried to implement
a compromise semantics that's compatible with Larceny's
R5RS semantics when no R6RS-style exception handlers
have been installed, but is intended to have R6RS-style
behavior when one or more R6RS-style exception handlers
have been installed. That doesn't appear to be working
as intended, and I don't yet understand why.

I'll file a bug report for this after I have tried a few
more things.

On the other hand, the R6RS mode appears to be working
as intended:

Error: no handler for exception #<record &compound-condition>
Compound condition has these components:
#<record &error>
#<record &who>
who : raise
#<record &message>
message : "handler returned"
#<record &irritants>
irritants : (#<PROCEDURE> #<record &compound-condition>)

Terminating program execution.

To avoid that error in R6RS mode, the handler should
not return, e.g.

(call/cc
(lambda (return)
(with-exception-handler (lambda (h) (return #t))
(lambda () (die)))))

Will

Loading...