what-a-guy a écrit :
> (defmacro dlg [dlgid# & fields#]
>   `(fn  [parent# layout#]
>      ~@(map
>       (fn [[f# id# text# type#]]
>         `(fld parent# layout# '~id# ~text# ~type#))
>       fields#)))
>
> (def inp '(dlg "test"
>              (field fld-1 "Field number one" (JTextField.))
>              (field fld-2 "Field number two" (JTextField.))))
>
> (macroexpand inp)
>
> ;; =>
> ;; (fn* ([parent__6 layout__7]
> ;;    (user/fld parent__4 layout__5 (quote fld-1) "Field number
> one" (JTextField.))
> ;;    (user/fld parent__4 layout__5 (quote fld-2) "Field number
> two" (JTextField.))))
>   

All parent# symbols will expand to the same symbol only if they are all 
inside the same backquote. When it's not the case you have to resort to 
explicit gensyming:

(defmacro dlg [dlgid# & fields#]
  (let [parent (gensym "parent")]
    `(fn  [~parent layout#]
       ~@(map
          (fn [[f# id# text# type#]]
            `(fld ~parent layout# '~id# ~text# ~type#))
          fields#))))

Christophe


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