On Sat, Oct 24, 2009 at 12:19 AM, samppi <rbysam...@gmail.com> wrote:

> user=> (defmacro b [form]
>  (let [processed-form (a form rec#)]
>    `(fn [rec#] processed-form)))
> java.lang.Exception: Unable to resolve symbol: rec# in this context
> (NO_SOURCE_FILE:39)


Try

(defmacro b [form]
  (let [r (gensym)
        processed-form (a form r)]
   `(fn [~r] ~processed-form)))

You need to replace rec# with a *reference* to a symbol. If you use a
literal symbol (including a literal gensym) it will try to take its value
even though you haven't assigned it yet. When you called a manually you
passed it a quoted symbol, so a symbol rather than the result of
dereferencing one. To get a symbol as the second argument to a in the macro
you need a pointer TO a gensym, which the first binding in my version of the
let gets you, in r.

You also need to unquote the expressions that should be filled in from the
let bindings. Otherwise you'd get (fn [r] processed-form) instead of (fn
[G_1746] (:a G_1746)) or whatever you actually want.

--~--~---------~--~----~------------~-------~--~----~
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
Note that posts from new members are moderated - please be patient with your 
first post.
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