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

Re: Finally clauses

This page is part of the web mail archives of SRFI 34 from before July 7th, 2015. The new archives for SRFI 34 contain all messages, not just those from before July 7th, 2015.

   Date: Tue, 13 Aug 2002 18:40:54 +0100
   From: Tony Garnock-Jones <tonyg@xxxxxxxxxxxxxxx>

   But "finally" isn't dealing with cleaning up on
   stack-unwinding - it's dealing with cleaning up on exception-raising
   (which doesn't involve any stack-unwinding at all, unless an
   individual exception-handler procedure decides to do a throw to a
   different dynamic environment).

It doesn't make sense to me to have "finally" clean up when an
exception is raised and no stack unwinding occurs.  Suppose we
build continuable exceptions on top of SRFI-34 and add
   (finally <exp> <body>)
that evaluates <exp> whenever an exception is raised in <body>
and when <body> returns. Then if we write

        (with-handler (lambda (c)
                        (if (continuable? c)
                            (continue c 10)
                            (raise c)))
            (finally (begin (display "exiting") (newline))
              (raise (make-continuable-exception))))

it will write "exiting" twice, once for the raise and once
for the normal return.  When would you use such a "finally"?