> That doesn't seem to be possible - I can't find a function that
> accepts a PersistentStructMap and returns the symbol passed to struct
> so it knows the keylist to use for the arguments. Nor could I find the
> magic incantation to let me use those symbol names with derive, which
> would let me use keywords for them. I got something working by having
> the dispatch function use sets of keys from the maps, but that seems
> fragile. Writing defFOO and FOO macros that attached the appropriate
> metadata to each struct seem possible, but sorta ugly.

I believe this is the current way to do it.  For each struct type I
intend to use in this way, I write a

(defn make-A [a b c]
  (with-meta (struct A a b c) {:type ::A}))

function and use this to construct all of my struct instances.

Future versions of Clojure will have datatypes [1], which improve on
structmaps in many ways (typed fields, real type fields for
multimethod dispatch, ...), as well as protocols [2], which will
replace many instances of multimethods.

[1] http://www.assembla.com/wiki/show/clojure/Datatypes
[2] http://www.assembla.com/wiki/show/clojure/Protocols

They are there in the "new" branch to be tried out, although I think
details are still subject to change.

-Jason

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to