Hi!

I have a little trouble writing a macro because I'm getting unexpected (for
me) behavior.

Let see some code:

(ns foo.bar)

(defn debug
  [x]
  (println "debug:" x)
  x)

(defn debug-expr?
  [expr]
  (and (seq? expr)
       (symbol? (first expr))
       *(= 'foo.bar/debug  (first expr))*))

(defmacro without-debug
  [& body]
  (let [body' (reduce (fn [acc v]
                        (if (debug-expr? v)
                          (conj acc (second v))
                          (conj acc v)))
                      [] body)]
    `(do
       ~@body')))


And then I use it from other namespace:

(ns foo.baz)

(require '[foo.bar :as b])

(macroexpand '(b/without-debug (b/debug 3)))
;; => (do (b/debug 3))

(macroexpand '(b/without-debug (foo.bar/debug 3)))
;; =>(do 3)

I expect that the both expressions will evaluate to the same result, but is
not. Seems that symbols inside macros are not fully qualified. It there any
way to get them fully qualified? I'm missing something?

Any help is welcome!

Thank you very much.

Andrey
-- 
Andrey Antukh - Андрей Антух - <n...@niwi.nz>
http://www.niwi.nz
https://github.com/niwinz

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to