On Mon, 2011-11-14 at 14:09 -0800, John McDonald wrote: > Structmaps can be defined either named, thru the defstruct macro, or > anonymously, thru the create-struct function call. Record types must > be named and defined thru a call to defrecord.
1.2-style records and types are very different from structs, so don't assume that what applies to one reasonably applies to the other. Namely: > This seems to contradict one of the Clojure library coding standards > (http://dev.clojure.org/display/design/Library+Coding+Standards): > "Don't use a macro when a function can do the job. If a macro is > important for ease-of-use, expose the function version as well." There is no function version of defrecord to expose, so this standard doesn't apply. defrecord needs a great deal of compiler support. It doesn't provide an ease-of-use wrapper for a simple Java method or function call, like defstruct does; it wraps deftype*, a compiler special form (primitive) whose contents must be present at compile-time for it to work. > So it looks like the choice is between struct-maps and records. Many > of the values are likely to be byte, short, etc., and it will be > important to save space with an un-boxed representation. > > It seem record plus type hints would be the best choice. I can work > around the missing function, by writing my own macro that calls eval, > but that doesn't smell nice. Each defrecord creates a Java class, normally stuck in memory forever unless you mess with the GC settings. I can't remember the details, but each eval might make a class, too, depending on its complexity. Offset the savings you get with unboxed representations by these costs when evaluating records as your solution. -- Stephen Compall ^aCollection allSatisfy: [:each|aCondition]: less is better -- 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