You might find this useful for examples:

http://david-mcneil.com/post/765563763/enhanced-clojure-records


On Monday, April 2, 2012 8:51:23 AM UTC-5, Joachim De Beule wrote:
>
> Hi All,
>
> I need to define a number of similar records, so I wanted to write a macro 
> for that, but I do not know how. Basically, I tried the following:
>
> (defprotocol MyProtocol (do-something [this]))
>
> (defmacro my-defrecord [name [& fields] & body]
>   `(defrecord ~name ~fields
>      MyProtocol
>      (do-something [this] this)
>      ~@body))
>
> But then when I call 
>
> (my-defrecord R [content]), 
>
> which expands into the following (valid) code:
>
> (defrecord R (content) tmp-protocol (do-sth [this] this)),
>
> Then I get the RunTimeException "No such var: this"? Any ideas?
>
> Best, Joachim.
>
>
>
>

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