On Tuesday, June 2, 2015 at 11:16:49 PM UTC-5, Steven Yi wrote: > > As a side note, as an experiment I just tried overriding Object.equals > and Object.hashCode with a defrecord, and I got a compiler error: > > CompilerException java.lang.ClassFormatError: Duplicate method > name&signature in class file user/R1, > compiling:(/private/var/folders/0k/xj_drd990xxf4q99n2bdknrc0000gn/T/form-init3397614882621384237.clj:1:1) > > > > I'm assuming that defrecord is adding its hashCode and equals > implementations without checking if it's being overridden, but haven't > verified. (That was with 1.7.0-beta3 at least). >
I just understood why you tried this experiment, I think. I tried it in 1.6.0 and 1.7.0-RC1 and got the same result. For my purposes, it would be ideal if I could override hashCode so that it was based on identity. I'd get speed with Java hashmaps along with the other conveniences of records. Oh well. Perhaps overriding hash behavior seems too bug-prone to be allowed. The docstring for defrecord mentions explicitly that it defines hashCode and equals. It seems as if there's a tiny inconsistency in the documentation given that it says that "You can also define overrides for methods of Object", though it doesn't say that you can do this for *all* of Object's methods; perhaps strictly speaking it's not inconsistent. -- 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.