No problem Evan,
(def constants (atom ()))
(defn add-constant [name x]
(let [sym (gensym name)]
(reset! constants (cons ([sym x]) @constants)
sym
))
Then when I produce code, I call add-constant and use the returned symbol.
(I only use it to produce new constants, which is the annoying part.
However, constants can be function)
At the end I call
(defmacro emit-all []
`(do ~@(reduce (fn [l [sym definition] ] (cons `(def ~sym
~definition) l) () @constants )
))))
That's ugly and I would like to find better.
Nicolas.
--
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