How about appending type metadata automagically...
(defstruct stuff :a :b)
(defmacro make
"Creates a new instance of struct t and appends 'type' t as metadata"
[t & vs]
`(with-meta
(struct ~t ~...@vs)
{:type (keyword (str *ns*) (name '~t))}))
user> (make stuff 1 2)
{:a 1, :b 2}
user> (meta (make stuff 1 2))
{:type :user/stuff}
-Jeff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---