clojure - Expanding macros in macros -


i have following macro :

(defmacro add-children [this children]   (map (fn [child] (list '.addchild child)) children)) 

and create following macro :

(defmacro defgom [name & body]  (let [sym (gensym)]   `(let [~sym (model.)]      (add-children sym body))))) 

considering model java class addchild function. expand defgom

(let [*gensym* (model.)]   (.addchild *gensym* (first body))   (.addchild *gensym* (second body))   ...   (.addchild *gensym* (last body))) 

when evaluated, add-children macro gives correct result (the list of .addchild). can't evaluate in defgom macro. "don't know how create iseq from: clojure.lang.symbol". tried ~ or ~@ (given add-children returns list), none worked.

how expand macro inside macro?

ps: know can function rather add-children macro, want know if it's possible macro.

just change last line to:

(add-children ~sym ~@body) 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -