I'm kind of a newb to these parts, but I disagree somewhat with Phil that structmaps are only useful as a performance optimization.
It also seems to me that because they make it convenient to create positional constructors for map structures, they make life much easier to concisely build data structures in a declarative style, without needlessly repeating keys in collection structures - something that will always be somewhat error prone. Some of the "DB rowset" examples in Rich's post are great applications for a structmap - why write :name on every row? That said, there are obviously limits beyond which positional constructors cause more problems than they solve, but I don't think that's a reason to recommend against positional constructors (and structmaps) wholesale. ..Mark.. On Sun, Mar 8, 2009 at 1:13 PM, Phil Hagelberg <p...@hagelb.org> wrote: > > Dan <redalas...@gmail.com> writes: > >>> I guess I want to advocate - don't merely replicate the things with >>> which you are familiar. Try to do things in the Clojure way. If your >>> logical structure is a mapping of names to values, please use a map. >> >> I tend to replace every instance of creating classes with creating >> structs which, if I understood correctly, are maps too. Good habit or >> should structs not be abused? > > I'm pretty sure structs are only appropriate for when you need to eek > the absolute last iota of performance out of a collection, in which case > they can provide greater speed than maps. But since the list of keys is > fixed, it means it's more effort to add or rename a key than it is with > a map. > > You shouldn't trade that flexibility for speed until (0) you are pretty > sure the keys are not going to change soon and (1) you know you can't > get the speed you need from maps. Neither of these are true when you're > just starting out on a piece of code. > > -Phil > > > > --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---