I'm sure it's not intentional, but it makes sense. In the first case, the
comparison delegates to `r`'s equals() method, which would return false because
{:a 1} isn't a `my-record`. In the second case, the comparison delegates to
`{:a 1}`'s equals() method, which is a PersistentArrayMap, which would return
true, because it's just looking for equality of map entries. Not sure how to
make this behave consistently without introducing a lot of weirdness into the
language.
-Fred
--
Science answers questions; philosophy questions answers.
On Jul 29, 2010, at 10:51 PM, Ryan Twitchell wrote:
> Hi all,
>
> I noticed (with a very recent git pull) the following asymmetric
> behavior regarding = and records:
>
> (defrecord my-record [a])
>
> (def r (new my-record 1))
> (def s (new my-record 1))
>
> (= r s) ;; true
> (= s r) ;; true
> (= r {:a 1}) ;; false
> (= {:a 1} r) ;; true
>
> Is this intentional? (I hope not)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en