> Am Dienstag, 6. September 2011 schrieb Alasdair MacLeod : > I guess the only gotcha is if a function treats the record as a map > and > tries to access a field by putting the record in function position: > > user=> (defrecord Person [first last]) > user.Person > user=> ((Person. "Joe" "Bloggs"):first ) > java.lang.ClassCastException: user.Person cannot be cast to > clojure.lang.IFn (NO_SOURCE_FILE:0) > > That's kind of bad, IMO. > > Is that on purpose? What's the rationale?
This is by design. Function position indicates that the data structure is a collection, not a (logical) record. > Aren't defrecords supposed to be drop-in specializations of maps? Where maps are used as records, but not where maps are used as collections. Stu Stuart Halloway Clojure/core http://clojure.com -- 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