I'm trying to create a macro called "procedure" so that:
  (procedure (and _x (pos? _y)))
expands to
  (fn [rec#] (and (:x rec#) (pos? (:y rec#))))

I'm stuck because I can't figure out a way to generate a symbol
outside. I'm a newbie at macros, so I don't know if there's a better
way around this:

Clojure 1.0.0-
user=> (require '[clojure.zip :as zip])
nil
user=> (defn a [form rec-symbol]
  (loop [loc (zip/seq-zip form)]
  (if (zip/end? loc)
    (zip/root loc)
    (recur
      (zip/next
        (let [node (zip/node loc)]
          (if (and (symbol? node) (-> node name first (= \_)))
            (zip/replace loc (list (-> node name (subs 1) keyword)
'rec))
            loc)))))))
#'user/a
user=> (a '(_a) 'rec)
((:a rec))
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)

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