On Tue, Dec 16, 2008 at 12:11 AM, Feng <hou...@gmail.com> wrote:
>
> Hi,
>
> Because clojure set, vector and map all implements
> java.util.Comparator (indirectly via AFn), they interact with
> java.util.TreeSet/TreeMap in surprising way due to overloaded ctor
> (java.util.Comparator).
>
> user=> (def s (java.util.TreeSet. [1 2 3 3]))
> #'user/s
> user=> s
> #=(java.util.TreeSet. #{})
> user=> (.add s 3)
> true
> user=> s
> #=(java.util.TreeSet. #{3})
> user=> (.add s 3)
> java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong
> number of args passed to: PersistentVector (NO_SOURCE_FILE:0)
> user=> (def m (java.util.TreeMap. {:a 1 :b 2 }))
> #'user/m
> user=> m
> #=(java.util.TreeMap. {})
> user=> (.put m :a 2)
> nil
> user=> m
> #=(java.util.TreeMap. {:a 2})
> user=> (.put m :c 3)
> java.lang.RuntimeException: java.lang.ClassCastException:
> clojure.lang.Keyword (NO_SOURCE_FILE:0)
>
> Is this an oversight or a compromise by design?
>

I've refactored Comparator into superclass of functions only (SVN
1161), i.e. collections no longer implement Comparator.

Thanks for the report,

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