Clojure中地图和集合之间的行为不一致

noa*_*hlz 2 clojure

Steve Losh 发布 了以下Clojure片段:

; Integers and Longs are equal.
(= (Integer. 1) (Long. 1))
true

; Even negative ones.
(= (Integer. -1) (Long. -1))
true

; When you use them as keys in maps, the maps are still equal.
(= {(Integer. 1) :foo} {(Long. 1) :foo})
true

(= {(Integer. -1) :foo} {(Long. -1) :foo})
true

; When you use positive numbers as keys to sets, they're also equal.
(= #{(Integer. 1)} #{(Long. 1)})
true

; But negative ones aren't. But only in sets. Maps are fine. lol.
(= #{(Integer. -1)} #{(Long. -1)})
false
Run Code Online (Sandbox Code Playgroud)

这种行为的原因是什么?它被认为是缺陷还是存在"形式逻辑"/集理论的原因,为什么(Integer. -1)不能(Long. -1)在持久集中等同?

Ste*_*osh 7

这是Clojure中的一个错误:http://dev.clojure.org/jira/browse/CLJ-1106

满足堆栈溢出的文本愚蠢的字符限制在这里