On Sat, 2012-11-03 at 13:57 -0700, Vladimir Tsichevski wrote:
> In one of my purely Java project I have to create hundreds of java classes 
> with repeatable structure, so the task is an excellent candidate for 
> automation. I hoped I will be able to create these classes with the latest 
> closure, using the 'deftype' construct.

If you know all the details of classes to create at compile time, you
can use macros instead, which are perfectly well able to output deftype
forms.  Untested:

(defmacro defrefs
  "Make a bunch of :x boxes."
  [& names]
  `(do ~@(map (fn [name] `(defrecord ~name [~'x])) names)))

;; makes classes foo, bar, baz, qux, quux, all with the :x field.
(defrefs foo bar baz qux quux)

-- 
Stephen Compall
^aCollection allSatisfy: [:each|aCondition]: less is better


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