deftype allows you to override hashCode and/or hasheq (I believe defaulting to identity-based implementations from java.lang.Object). defrecord does not.
As mentioned in another message, potemkin may provide easier building blocks to build on than deftype. Andy On Thu, Jun 11, 2015 at 11:10 PM, Mars0i <marsh...@logical.net> wrote: > > > On Thursday, June 11, 2015 at 2:19:56 PM UTC-5, Andy Fingerhut wrote: >> >> You can override hashCode and/or hasheq methods in deftype. >> > > I've been unable to do it. Is there something special needed to allow > this to work? > > user=> (defrecord Foo [x] Object (hashCode [this] 42)) > CompilerException java.lang.ClassFormatError: Duplicate method > name&signature in class file user/Foo, > compiling:(/private/var/folders/hv/hv6wzwrEFOujYN382REV6++++TI/-Tmp-/form-init7644007787939926514.clj:1:1) > > > user=> (defrecord Foo [x] Object (hasheq [this] 42)) > CompilerException java.lang.ClassFormatError: Duplicate method > name&signature in class file user/Foo, > compiling:(/private/var/folders/hv/hv6wzwrEFOujYN382REV6++++TI/-Tmp-/form-init7644007787939926514.clj:1:1) > > > > If the reason that defrecord hashing is slow in your application is > because _hasheq_ recalculates the hash values from scratch each > > time, without _caching the value_, consider voting for this ticket so > that is improved in the future: > http://dev.clojure.org/jira/browse/CLJ-1224 > > I'm not sure whether this might be a part of what I'm experiencing, but I > didn't know about the ticket-voting process. I'll look into that. > > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.