The reason arrays don't compare as equal, in clojure, is because they can change at any time, and objects which are equal should stay equal. Imagine a map like {rec1 1}
. If your two objects compare as equal, I should be able to look up rec2
in it and find the answer 1
. But if someone does (aset (:field rec2) 1 3)
, suddenly rec2
has changed, and is no longer equal to rec1
!. This is just not something that should happen, so clojure says they're not equal.
This is similar to the equality semantics for atoms and other mutable containers: just because two mutable containers (atoms, or arrays) have equal contents now doesn't mean the containers are themselves equal. That tenuous equality could change at any time, when someone modifies one of them. Similarly, your two arrays may become unequal at any time; this means that, really, they were never equal at all.