Thanks for the ticket pointer. I didn't find it in my initial search 
because it "Affects Version/s: None" :-/, and I knew this behavior was new 
to 1.6.

For those not up for the medium-length comment-thread read: 
non-Clojure-aware Java Collections Framework interface instances are not 
considered values,* and 'Rich says "all bets should be off for hasheq/equiv 
of non-values."' That's a bit down in the details, but I think the upshot 
is that they're not currently supported as set members or hash keys. 
Unfortunately they used to be supported (unintentionally, I guess) due to 
Clojure following Java's lead, so I have some interop-heavy code to review 
and test very carefully. Though the above seems to frame non-support as 
based on principle, it seems the driver is keeping the new hasheq stuff 
highly performant. I would hope a performant implementation that supported 
the Collections interfaces would be accepted for some future version.

*If there is one, I'd like to read a clear definition of what "values" 
means in Clojure. The headings on http://clojure.org/data_structures are 
almost an enumeration of them, except the "Collections" section talks a 
little about Java Collections classes, hashCode, and hasheq without making 
it clear that non-Clojure collections are not values. Unfortunately the 
current definition seems to admit only the Java primitives and 
near-primitives (String and primitive wrappers) and clojure-aware types.

What "not supported" looks like via maps:
user> *clojure-version*
{:major 1, :minor 6, :incremental 0, :qualifier nil}
user> (hash-map [1 2] "v" (java.util.ArrayList. [1 2]) "a")
{[1 2] "a", [1 2] "v"}
user> {[1 2] "v" (java.util.ArrayList. [1 2]) "a"}
IllegalArgumentException Duplicate key: [1 2] 
 clojure.lang.PersistentArrayMap.createWithCheck 
(PersistentArrayMap.java:70)
user> (-> {} (assoc [1 2] "v") (assoc (java.util.ArrayList. [1 2]) "a"))
{[1 2] "a"}


On Friday, May 9, 2014 6:34:26 PM UTC-5, Andy Fingerhut wrote:
>
> Mike is correct.  This change in behavior is due to the hashing changes in 
> Clojure 1.6.  See the comments on ticket 
> http://dev.clojure.org/jira/browse/CLJ-1372 for some discussion of 
> whether this is considered a bug.  It appears that perhaps the hash 
> consistency is not promised for mutable objects, only immutable ones.
>
> Below are a couple more REPL transcripts that illustrate the change in 
> behavior:
>
> user=> *clojure-version*
> {:major 1, :minor 5, :incremental 1, :qualifier nil}
> user=> (= [1 2] (java.util.ArrayList. [1 2]))
> true
> user=> (map hash [ [1 2] (java.util.ArrayList. [1 2]) ])
> (994 994)
> user=> (hash-map [1 2] "vec" (java.util.ArrayList. [1 2]) "alist")
> {[1 2] "alist"}
>
>
>
> user=> *clojure-version*
> {:major 1, :minor 6, :incremental 0, :qualifier nil}
> user=> (= [1 2] (java.util.ArrayList. [1 2]))
> true
> user=> (map hash [ [1 2] (java.util.ArrayList. [1 2]) ])
> (156247261 994)
> user=> (hash-map [1 2] "vec" (java.util.ArrayList. [1 2]) "alist")
> {[1 2] "alist", [1 2] "vec"}
>
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to