When records were first introduced there was a little debate over what the 
behavior of first case should be. If = is defined solely in terms of 
.equals then two different records with the same key/value mappings must 
[1] be = to each other to obey the contract of the Map interface even 
though the values are likely meant to be conceptually distinct. For 
instance if you had (defrecord Square [length color]) and (defrecord Rope 
[length color]), then you would have (= (Square. 1 :red) (Rope. 1 :red)) 
even though a red square is not the same thing as red rope.

To work around the issue, = was changed to be in terms of equiv (see the 
definitions in [2]). This allows compliance with the Map interface and 
prevents (= (Square. 1 :red) (Rope. 1 :red)).

[1] One idea was to have a hidden key corresponding to the record's type be 
visible when using the Map interface; that would cause a great deal of 
complexity and was rejected.
[2] 
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Util.java

-- 
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

Reply via email to