Hi all,
I'd like to have a macro that I can call and pass it some function that
the macro uses inside. Concretely, the macro iterates over some class
model and should expand to a ns declaration with one defn per class in
the model. Currently, the macro calls a generate-defn-for-class
function internally that returns a valid defn-form like so.
(defmacro mymacro [model-file]
(let [model (load-model model-file)]
`(do
;; ...
~@(for [class model]
(generate-defn-for-class class)))))
That works fine, but now I have a similar use-case where different defns
have to be generated. So I'd like to refactor my macro so that I can
pass it a defn-generating function. However, that doesn't seem to work.
Here's a super-minimal version of what I'm trying to do:
(defmacro do-do [x afn]
`(do ~(afn x)))
So when I'd call it like
(do-do 1 inc)
I'd expect it to expand to (do 2). However, it expands to (do nil).
Why is that?
Bye,
Tassilo
--
--
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
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.