Welcome! Please see the About page for a little more info on how this works.

0 votes
in data.int-map by

Most implementations of Clojure immutable maps and sets can return true when being compared against java.util.Map and java.util.Set instances (even mutable ones) if they currently have the same contents.

The proposed patch to enable this for int sets and int maps has a test case that demonstrates this is not true for the latest library code.

I would expect to get true for all of the .equals and = calls in the sample REPL session below.

`
user=> (def jset1 (java.util.HashSet. [1]))

'user/jset1

user=> (def intset1 (imap/int-set [1]))

'user/intset1

user=> (def cset1 #{1})

'user/cset1

user=> (.equals cset1 jset1)
true
user=> (= cset1 jset1)
true
user=> (.equals jset1 cset1)
true
user=> (= jset1 cset1)
true
user=> (.equals intset1 jset1)
false
user=> (= intset1 jset1)
false
user=> (.equals jset1 intset1)
true
user=> (= jset1 intset1)
false
`

2 Answers

0 votes
by

Comment made by: jafingerhut

Patch dimap-16-v1.patch is one possible approach to fix this issue, I believe. It is modeled on similar code for Clojure's built-in .equals and .equiv methods for sets and maps, which check against java.util.Set and java.util.Map interfaces, vs. clojure.core/set? and clojure.core/map?, which are more restrictive.

0 votes
by
Reference: https://clojure.atlassian.net/browse/DIMAP-16 (reported by jafingerhut)
...