symbol-capture

Accessing a local from one macro in another executed in the scope of the let.

Be gentle, as my macrofoo is weak. What I'd like to do is something like this: (defmacro foo [x] `(dosync (alter x# conj x))) (defmacro bar [] `(let [x# (ref [])] (foo 3))) Is this possible? I can't just (let [x ..] ..) because of symbol capturing. NOTE: I'm aware this example is trivial and not macro-worthy, but it's the simplest e...

Avoiding symbol capture when using macros to generate functions (or other macros)

I'm a bit confused as to exactly when symbol capture will occur with clojure macros. Suppose that I have a macro which defines a function from keywords. In this trivial example, (defmacro foo [keywd1 keywd2] `(defn ~(symbol (name keywd1)) [~(symbol (name keywd2))] (* 2 ~(symbol (name keywd2))))) I call (foo :bar ...