Hi, I would like to know why defstruct without providing any keys (like "(defstruct s)") is not allowed (exception: "Must supply keys").
Let me shortly describe why I think that this would be useful: Imagine you have a defstruct like in Rich's Ants demo: (defstruct cell :food :pher) ;may also have :ant and :home :ant and :home are optional, since they are not often used (Rich actually states in his talk, that this is an advantage compared to Java where we would always have to store "null" for each of the optional class members). Image, you use (struct-map cell ...) very often in your program. Now, you notice that :food and :pher are also not used very often, and that most times only one or two of the four possible keys are actually used. So you make them all optional: (defstruct cell) ;may have :food, :pher, :ant and :home This is not allowed. You have to remove the whole defstruct, which makes all your (struct-map cell ...) calls useless. This is bad, because you have to replace it everywhere and struct-map has a very nice documentary style you want to use anyway. (Later, when we notice that at least one key is obligatory, we again have to find these places and convert them back to struct-map...) In practice, I had this problem with a struct containing 10 possible keys, where mostly only 1-2 are used in practice. Now I have to remove the whole defstruct... or let at least one arbitrary key be non- optional, which is more a hack than a nice solution. Looking in the PersistentStructMap.java, I found out that allowing structs with no obligatory key would be no problem at all (change 2 lines?). I don't know why it was written that way, but I think here Clojure puts a spoke in me wheel where it just not needed. Any comments? Thanks! Andi
-- 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