I'm attempting what should be a simple macro transformation (dlg below): (defn fld [parent lay id text field] '...)
;; dlg macro. For this input: ;; ;; (dlg "test" ;; (field fld-1 "Field number one" (JTextField.)) ;; (field fld-2 "Field number two" (JTextField.))) ;; ;; we want this output: ;; ;; (fn [parent layout] ;; (fld parent layout 'fld-1 "Field number one" (JTextField.)) ;; (fld parent layout 'fld-2 "Field number two" (JTextField.)) ;; parent) (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.)))) (eval inp) ;; => ;; java.lang.Exception: Unable to resolve symbol: parent__4 in this context (NO_SOURCE_FILE:24) The dlg macro seems to be generating 2 different symbols for 'parent, when I'd like both to refer to the same symbol. Any suggestions? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---