On Aug 2, 3:50 pm, Baishampayan Ghose <b.gh...@gmail.com> wrote: > Hello, [snip..] > The documentation says "defrecord provides a complete implementation > of a persistent map". If a record is analogous to a map, why can't we > treat it as one? > > If it's not a bug, what is the rationale behind it? > > Regards, > BG
Hi BG, It is a common mistake to think that callability, corresponding to the clojure.lang.IFn interface, is part of the persistent map contract (I've done it myself, as did many others a Conj labs :). It is not. It is actually just a feature of clojure.lang.PersistentHashMap (and the other clojure map implementations). I haven't looked at the compiler, but I think that defrecord creates a class that implements clojure.lang.IPersistentMap (among others). Note, Christophe pointed out to me: this is also relevant when you are extending a protocol to clojure.lang.IPersistentMap: don't rely on callability when accessing the map (this was the mistake I made). Kind Regards, Karl. -- 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