Details
-
Type:
Enhancement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Completed
-
Affects Version/s: Release 1.2, Release 1.3, Release 1.4
-
Fix Version/s: Release 1.3, Release 1.4
-
Component/s: None
-
Labels:None
-
Approval:Accepted
Description
http://groups.google.com/group/clojure/browse_frm/thread/eba691b38c45196b#
The docstring of defrecord says it "will define type-and-
value-based equality and hashCode". In reality, record types are included in = but not .equals (or hashCode), and so records of different types can collide as map keys.
Along the same lines, the docstring of = says "same as Java x.equals
, except it ... compares numbers and collections in a type-independent manner". To me, this seems to imply the opposite of what actually happens with records.
FWIW I think it would be more clear if the behavior for = and .equals were the same in this respect, but in any case the implemented behavior should be properly documented.
Also discussed at https://groups.google.com/d/topic/clojure/e6UhXVny8Xc/discussion
Per Rich, "The policy is: = includes the type and .equals doesn't. In this way records can still be proper j.u.Maps and = remains most useful for records (e.g. including type)."