Michael Erdmann wrote:
[...]
The interface i a little bit funy but look very mutch
like the try...catch construct of java.
;; creating an intecepting an exception
(call-with-current-continuation
(lambda (exit)
(handle-exceptions exn
(begin (put-line "Went wrong") (exit exn) )
(put-line "Expression 1")
(abort 'x)))
)
Java:
try {
Expression1
throw ..
}
catch(Exception e) {
}
I can even use vectors or records to build exception types. Fine! Only
this call-with-current-continuation is clumsy.
[...]
If it's only the clumsy function name you dislike, you can write call/cc
instead of call-with-current-continuation -- that's not R5RS but a very
common abbreviation supported by many Scheme implementations.
But the call-with-current-continuation in your example above is
completely superfluous. You could write
(handle-exceptions exn
(begin
(put-line "Went wrong") exn)
(put-line "Expression 1")
(abort 'x))
instead and get exactly the same behaviour. (Nevertheless
call-with-current-continuation is used internally by handle-exceptions
to do what it does...)