chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Expecption Handling with chicken


From: Thomas Chust
Subject: Re: [Chicken-users] Expecption Handling with chicken
Date: Sat, 02 Oct 2004 16:58:42 +0200
User-agent: Mozilla Thunderbird 0.5 (X11/20040306)

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...)

cu,
Thomas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]