[Scheme-reports] 6.1 Exceptions needs examples Per Bothner (20 Mar 2012 05:47 UTC)
Re: [Scheme-reports] 6.1 Exceptions needs examples John Cowan (21 Mar 2012 03:29 UTC)
[Scheme-reports] Exceptions on JVM [was: Exceptions needs examples] Per Bothner (06 Jan 2014 05:36 UTC)

[Scheme-reports] Exceptions on JVM [was: Exceptions needs examples] Per Bothner 06 Jan 2014 05:26 UTC

This is a belated follow-up to a discussion about implementing
r7rs exceptions on the JVM, and specifically:

http://lists.scheme-reports.org/pipermail/scheme-reports/2012-March/001982.html

FYI, I have implemented r6rs/r7rs-style exceptions on Kawa, roughly as
suggested in the message above.  I originally implemented guard using
the macro in R7RS, using with-exception-handler.  I also implemented
a 'simple-guard' using the same syntax as 'guard', but using a cond
inside a (native JVM) try-catch. (I used the guard-aux from r7rs.)
This worked for the test/examples I've seen, but of course
raise-continuable wouldn't get handled by a 'simple-guard'.
So I implemented John Cowan's suggestion: Changed simple-guard
to push a special mark (#!null) on the handler stack, and then
just replaced guard by the simple-guard implementation.

This implementation handles most test-cases - though not Hulmut
Eller's more complex example with dynamic-wind (in the followup
to the above-linked message).

Performance will be a little slower than using "native" exception
handling (try-catch, try-finally, and primitive-throw), but it shouldn't
be too bad.  guard will normally be more efficient than
with-exception-handler:
guard is roughly a try-catch combined with a cond, though there is slightly
more overhead than that.  (See the code in kawa/lib/exceptions.scm.)
with-exception-handler will normally be able to inline the body 'thunk'
(if it is a lambda expression), but it can't inline the handler.

The source, if anyone is curious, is here:

https://sourceware.org/viewvc/kawa/trunk/kawa/lib/exceptions.scm
https://sourceware.org/viewvc/kawa/trunk/kawa/lib/ExceptionClasses.scm
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports