On Tue, Jan 25, 2011 at 1:04 PM, Shantanu Kumar <kumar.shant...@gmail.com>wrote:

I can't see the value in catching Throwable and then re-throwing it;
> idiomatically Throwable is rarely caught. Looking at code example, the
> following two snippets below are just the same:
>
> (try
>  (.close resource)
>  (catch Throwable t
>    (when (instance? Error t)
>      (throw t))))
>
> (try
>  (.close resource)
>  (catch Exception e))
>

(I don't think we want to discard the exception from close - Ken's code
still throws it if the body didn't throw an exception.)


> Besides, looking at the Java spec
> http://download.oracle.com/javase/6/docs/api/java/lang/Error.html


Clojure isn't Java though.  Bytecode corresponding to Java source code for a
try/finally block effectively catches Throwable via an 'any' entry in the
exception table, and then rethrows it.  Clojure should do something similar
or better.

See:
http://java.sun.com/docs/books/jvms/second_edition/html/Compiling.doc.html#13789

(although compilers generally inline the finally block nowadays, rather than
using the slower jsr instruction).

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