On Dec 17, 8:31 am, Ken Wesson <[email protected]> wrote:
> > 2. Is there a form for anonymous macros?
>
> Nope. I'm not sure why you'd want one, either.
This was my reaction too, but after some thought I can imagine
scenarios where it would be useful. For example, say I want to defn
several versions of the same function, with slightly different
options:
(defn quiet-foo [x]
(magic x :quiet))
(defn loud-foo [x]
(magic x :loud))
I could write a macro to do this, then call the macro N times for my N
functions:
(defmacro make-foo [name opt]
`(defn ~name [x#]
(magic x# ~opt)))
(make-foo quiet-foo :quiet)
But it might be nice to have some syntax like:
((macro [& name-opts]
(doseq [[name opt] (partition 2 name-opts)]
`(defn ~name [x#]
(magic x# ~opt))))
[quiet-foo :quiet, loud-foo :loud])
--
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