defrecord with identity as an equality semantic

2010-07-17 Thread Nicolas Oury
Dear all, I was wondering if they were a way to define a record type with identity as an equality semantic? (defrecord A[] Object (hashCode ...) (equals ...)) do not work. Is there a way to do that? (Defining a deftype around the defrecord is a bit annoying) Best regards, Nicolas. --

Re: defrecord with identity as an equality semantic

2010-07-17 Thread ataggart
No. Use identical? if you want to test for object identity. IIRC Rich commented that the inability to override equals/hashCode was intentional as value equality was the correct approach. See http://clojure.org/state On Jul 17, 7:00 am, Nicolas Oury wrote: > Dear all, > > I was wondering if th

Re: defrecord with identity as an equality semantic

2010-07-17 Thread Nicolas Oury
Well. I totally agree that value equality is the correct approach. And I am very happy it is the default. But, in some situations, you want to have accessors but do want to have identity as an equality. You cannot use identical? in Clojure data structures, for example. I am in a situation where

Re: defrecord with identity as an equality semantic

2010-07-17 Thread Nicolas Oury
More specifically, I am trying to build Hash Consed trees whose nodes are records. http://en.wikipedia.org/wiki/Hash_consing This is a necessary step in a lot of algorithms. It is a benefit of being principled about not mutating values. And it can not be implemented, without overriding hashCode