On Jan 18, 2011, at 5:03 PM, Alan wrote: > Deprecated doesn't mean "in future this will stop working" - it means > "you shouldn't use this". See eg > http://dictionary.reference.com/browse/deprecate.
None of those definitions appear to address this technical usage, and in my experience "deprecated" in this context often does mean "expected to go away." OTOH if defstruct isn't expected to go away then I'm happy, regardless of what anyone calls it. > Records behave the same as structs: they are maps, which you can > assoc, dissoc, and get from. Neither one is actually a > clojure.lang.PersistentMap, so there's no "elegance and flexibility" > that struct-maps have which is missing from defrecords. My > understanding of the differences is: > > - defrecords are real host-level classes, making interop easier > - defrecords are faster and smaller > - defstruct fields default to nil if you don't pass a particular key > in the constructor > - defstructs implement IFn, so you can call (m :a) as well as (:a m) > > The latter two are convenient features, but if records behaved that > way it would be bad for performance. And frankly if you're creating a > struct to hold :a and :b but don't feel like specifying :b this time, > why do you have a struct at all instead of a plain hash-map? If I recall correctly the lack of nil defaults was indeed one of the things that I didn't like about records (I think this was leading to exceptions in my code until I patched around it), and it's even possible that the IFn thing meant that I had to flip some code around. The reason I don't use a plain hash-maps is that defstruct documents my intent and also because I get all of the base keys in the struct-map even if I haven't assoced them, which can be nice in some circumstances e.g. for uniformity when printing these things. All of this is admittedly minor, but defstruct does what I want so it'd be nice if it kept doing that. > That is, defstructs are a slightly more-performant versions of > hashmaps: if you don't care about performance and want the convenience > of hashmaps...use hashmaps! If you do care about performance, use > records, which are more performant and discourage usage that will > detract from performance. Structmaps have a few features beyond plain hashmaps, and I happen to like them, so I'd like to keep using them. If I can't then that's no big deal and I can work around it, but I was just looking for some clarity on this. -Lee -- 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