On Mar 15, 4:44 am, B Smith-Mannschott <bsmith.o...@gmail.com> wrote: > On Mon, Mar 15, 2010 at 06:50, ataggart <alex.tagg...@gmail.com> wrote: > > Exceptions are over/mis-used in java, particularly checked exceptions > > (runtime exceptions aren't so bad). My sense is that those places > > where java.lang.Exception is thrown, the exception is not expected to > > be handled by user code, or perhaps more accurately, a direct result > > of a bug fat-fingered into the user code, e.g.: > > user=> (+ 5 foo) > > java.lang.Exception: Unable to resolve symbol: foo in this context > > (NO_SOURCE_FILE:1) > > That's my impression too. Unfortunately it's inconsistent with Java > convention. Java generally uses (extensions of) RuntimeException for > such cases. Other extensions of Exception are reserved for cases you > *are* expected to handle.
How do you expect to handle an exception thrown by the compiler? Just take a look at this: user=> (defmacro foo [] (try `(+ 5 bar) (catch Exception e (println "caught ex")))) #'user/foo user=> (foo) java.lang.Exception: No such var: user/bar (NO_SOURCE_FILE:4) Again the only exceptions that can be handled by user code are in fact RuntimeExceptions. > The fact that Clojure frees us from the tyranny of checked exceptions > is nice. The fact that it then turns around and uses what are > conventionally *checked* exceptions as if they were unchecked can only > appear sloppy from the point of view of other JVM languages calling > Clojure code. Give me an example please. In the case above, it actually isn't just a raw Exception: user=> (type *e) clojure.lang.Compiler$CompilerException > > IMHO Clojure should be throwing (extensions of) RuntimeException > unless it's just passing through an Exception originating form some > lower-level call into the JRE. It does. -- 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