On 24.10.2008 13:39 Uhr, Rich Hickey wrote:
>> user=>  (test-fn)
>> finally clause
>> java.lang.RuntimeException: user.UserException: thrown exception
>> (NO_SOURCE_FILE:0)
>>
>> So am I doing something wrong or is this a bug when an exception is
>> thrown from inside a call to map?
>>
>
> Currently ISeq (the interface for seqs) doesn't declare any exceptions
> on first/rest, therefor no implementations, e.g. LazyCons, can throw
> checked exceptions. So, if they encounter an exception in the
> implementation closure, they have to wrap it in an unchecked
> exception, like RuntimeException.
>
> This is a good example of why checked exceptions are bad - they force
> intervening parties who should have no participation in the process to
> be involved in exception declarations and handling, thereby thwarting
> the basic premise of exceptions - communication between the party that
> had the problem and the party that can do something about it.
>
> In any case, the only way to fix this is to declare that first/rest
> throw Exception in ISeq, which would be a big change (because
> everything that calls them would then have to declare exceptions, and
> everything that calls them... - complete inanity).

coming from a Java perspective, what's wrong with the clojure plumbing 
catching all Exceptions and wrapping them in a (checked) 
ClojureException - maybe derived from Throwable, so it wouldn't 
interfere with Java's exception hierarchy - which (catch) would then 
unwrap. Of course this would imply most of Clojure's Java implementation 
declaring "throws ClojureException", but this would unify the exception 
handling "interface" towards code written in clojure.

   --Chris

PS: Rich, I'm CC'ing you, because I've never been able to post to the list.

> They definitely weren't thinking about closures and higher-order
> programming when they invented checked exceptions - it invariably
> leads to everything declaring they throw the root Exception, so why
> bother?
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to