> apache commons io and spring framework, to name 2 things I know for
> sure, are doing what you say: they swallow any exception that could be
> thrown within the finally block, for the reasons you mention.

True, but if the body doesn't throw an exception, but the close does,
I wouldn't want the close exception swallowed.

Consider if you are writing to a socket via a buffered stream -
nothing may be written until the buffer is flushed when you call
close().  This is of course why close() throws Exception in the first
place.

Nested try/finally like clojure does, is what I tend to do in Java
else things get too verbose, but it would be possible for the
with-open macro to take the pain out of doing things slightly more
robustly.

A solution might be to change the macro to create a with-local-var var
at the top, and to add catch blocks with each finally that first
preserve the exception in the var.  At the end of the block if any
exception was stored in the var, it should be rethrown, otherwise the
expression value should be returned.

-- 
Dave

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to