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.

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."

My particular problem is the following: I read a set of data, say from
a CSV file with column headers. I  produce a representation of the
data as a sequence of cases where each case is a a collection of
annotated key-value pairs. The annotation describes the possible
values that can be associated with a given key, and is usually
determined by introspection on the values that I just read. The
annotation is used to determine details of how certain machine
learning methods can be applied to that data.

I want the case representation to be as compact and speedy as
possible.
The number of cases x number of keys may exceed 10^9, so I don't want
to repeat the actual keys and annotation with each case, and so using
bare maps seems unlikely to be a good solution.

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.

(PS: 'create-struct' is an unfortunately confusing name. It sounds
more like instantiation of an existing structure definition than a new
definition.  I'd suggest 'define-record' or 'create-record-definition'
for the function equivalent of 'defrecord'.)

-- 
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

Reply via email to