The problem is what does empty mean in the context of defrecord? A new instance of a defrecord is not "empty", it has those fields and they are set to nil.
David On Tue, Sep 27, 2011 at 3:48 AM, Nathan Sorenson <n...@sfu.ca> wrote: > I'm using clojure.walk/postwalk to rewrite terms in nested data > structures. However, I am unable to do this with types as defined by > defrecord, because they specify that the function "empty" throw a not- > implemented exception. > > If I were able to over-ride this default implementation of 'empty' I > believe I could still use postwalk to rewrite my custom records (as > they happily implement 'into' which works as expected.) > > This was my obvious first attempt: > > (defrecord TypeVar [guid name] > clojure.lang.IPersistentCollection > (empty [coll] (TypeVar. 0 nil))) > > Which fails due to: > > "Duplicate method name&signature in class file types/TypeVar" > [Thrown class java.lang.ClassFormatError] > > I would prefer not to fall back on deftype as I do wish these objects > to behave as maps. I also could write my own version of postwalk that > doesn't call 'empty' on my custom-defined records, but it would be > nice to make my types adhere to the contract of IPersistentCollection > as much as possible. -- 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