Hmm, I get a stack overflow when trying that make macro.
After using macroexpand-1...
(with-meta (struct stuff 1 2) {:type (keyword (str *ns*) (name (quote stuff)))})
I still get the stack overflow.

I'm on svn 1307, jdk 1.5 mac osx.
Any ideas?

Regards, Adrian.

On Thu, Feb 26, 2009 at 7:08 AM, Jeff Valk <jv-li...@tx.rr.com> wrote:
>
> 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 clojure@googlegroups.com
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