Check out the part of this page on "syntax quote" http://clojure.org/reader
As I understand it, syntax-quote namespace-resolves symbols to prevent accidental variable capture. 90% of the time, any variables you let within a macro should be suffixed by a "#". So, if you replace all occurrences of fd, controller, control, etc. with "fd#", "controller#", "control#", you should be taking a step in the right direction. (This improves the CL behavior of having to manually create gensyms outside of the macro-generated body if you want to write hygenic macros). HTH, Jason On Feb 23, 12:25 pm, max3000 <maxime.lar...@gmail.com> wrote: > Hi, > > I'm new to lisp and clojure, so what follows may be a very easy (i.e. > stupid) question... > > I want a macro to generate multi-methods. Here is the macro I crafted: > > (defmacro mcf [type class set-expr & forms] > '(defmethod make ~type [fd controller] > (let [control (new ~class)] > (doto control > ~@(map (fn [f] f) forms) > (~set-expr (. controller link control (:uid fd))))))) > > For instance, I want this: > (mcf :String JTextField .setText (.setColumns 15) (.setEditable > false)) > > To generate this: > > (defmethod make :String [fd controller] > (let [control (new JTextField)] > (doto control > (.setColumns 15) > (.setEditable false) > (.setText (. controller link control (:uid fd)))))) > > For some reason, controller, link, control and fd don't seem to be > handled properly. No matter what escaping I try (quotes, semi-quotes), > I always get some error similar to "No such var: clojure.core/link". > > Clojure seems to think "link" is a variable in the namespace while it > is in fact a (java) method on the controller. I just want to output > the last part verbatim (. controller link control...), I want no ahead- > of-time dereferencing... > > What am I missing? Is it even possible? > > Thanks, > > Max --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---