guile-user
[Top][All Lists]
Advanced

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

Re: Is there a way to transparently re-throw?


From: Keisuke Nishida
Subject: Re: Is there a way to transparently re-throw?
Date: Thu, 01 Mar 2001 20:54:39 -0500
User-agent: Wanderlust/2.4.0 (Rio) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.0.96 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

At 27 Feb 2001 12:00:44 -0600,
Rob Browning wrote:
> 
> I was trying to set up a catch handler that would catch all
> exceptions, take some cleanup action, and then, if the error wasn't
> one the handler was particularly interested in, re-throw the error
> *without* affecting the error's source.
> 
> You can almost do that like this:
> 
>   (define (handle-throw key . throw-args)
>     (cleanup)
>     (if (eq? key 'foo)
>         (do-something)
>         (apply throw key throw-args)))

Why don't you use dynamic-wind?

  (catch 'foo
    (dynamic-wind
      (lambda () (init))
      (lambda () (body))
      (lambda () (cleanup)))
    (lambda (key . args)
      (do-something)))



reply via email to

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