In Clojure, instances of defrecord are not = to regular maps with the
same content, nor with other defrecord instances of other types. This
is clearly a design choice and has been discussed before, but I
haven't found anywhere a justification of this choice.
(ClojureScript doesn't behave exactly the same way, currently, but I
assume these are just bugs.)
Here are the bits of answers I have found:
The defrecord doc string mentions value-and-type equality, but doesn't
justify it. (note
http://clojure.org/datatypes says only value-based
equality)
Rich describes including type in = as "most useful" here:
http://groups.google.com/group/clojure/msg/5a143969fe80bcf9
There is also discussion of why user-defined equality is undesirable,
with which I have no argument.
Related facts:
- lists and vectors have many differences (implementing IFn vs. not,
conj vs seq ordering) and yet they can be equal.
- most clojure collections fall into one of three equality
"partitions", but each defrecord type effectively defines it's own
partition
- defrecord equality depends on the concrete type of the record
itself, a rare dependence on concrete type in clojure
So why is it best for = to take into account the concrete types of
records, and also to ignore the differences in types between vectors
and lists?
--Chouser