Hi Rich,

I am very interested in your view of the world - why are 'checked'
exceptions evil?

Thanks
-Ralf

On Thu, Dec 11, 2008 at 2:08 PM, Rich Hickey <richhic...@gmail.com> wrote:

>
>
>
> On Dec 10, 10:52 pm, "Stephen C. Gilardi" <squee...@mac.com> wrote:
> > On Dec 10, 2008, at 4:38 AM, Ralf Bensmann wrote:
> >
> > > Being a Java trainer for a long time, we talk with students about
> > > the "handle-or-declare rule" in Java and the two types of
> > > exceptions: "checked" (declared) and "unchecked" (runtime). So I
> > > prefer using a RuntimeException because no exception was specified.
> >
> > I'm inclined to accept the recommendation to make RuntimeException the
> > default. I see that Clojure's Java source code uses both. It seems to
> > me that within Clojure, the distinction doesn't matter, but in the
> > case of Java interop, RuntimeExceptions would be more in keeping with
> > what Clojure's "never declare them" philosophy.
> >
> > Does anyone have any more advice on this?
> >
>
> Clojure doesn't have 'checked' exceptions. They are a bad idea, and a
> misfeature of Java, bad enough with interfaces but completely
> incompatible with closures. As a result of the flawed logic that has
> grown up around this misfeature, in Java you might choose between
> checked and non-checked based on whether you thought a caller could do
> anything about it - if not, use unchecked, thus making your method one
> that didn't require explicit handling.
>
> Given that there are no 'checked' exceptions in Clojure, the
> distinction is moot, except in the case of Java interop, where, at
> least through the IFn interface, all Clojure calls declare Exception.
> RuntimeException is a particularly dubious notion, a special exemption
> granted to those exceptions the Java runtime might throw, created in
> acknowledgment of the insufferable pain it would cause to use the
> checked exception system for those. If it were a fixed set it would be
> one thing - every caller could expect one of those (enumerated,
> documented) exceptions, or a declared one. But RuntimeExceptions are
> an open set - it's just plain goofy.
>
> Clojure's Java code throws explicit RuntimeExceptions only in those
> places where the checked exception system precludes it from letting an
> Exception flow out, and it pains me every time.
>
> I guess my recommendation is, if there is an existing exception type
> (checked or unchecked) that roughly matches your problem, throw that,
> else throw Exception. In this case, perhaps the default should be
> IllegalArgumentException.
>
> Rich
>
>
> >
>

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