Hello everybody,
 I am not sure if this is the expected behaviour .. or I am using it
incorrectly .. The code is pasted at
https://gist.github.com/716293 .

(ns symbol-macro-problem
  (:require [clojure.contrib.macro-utils :as m]))

(defmacro sym-macro [& body]
  `(m/symbol-macrolet [begin :begin
                       end :end]
                      (m/with-symbol-macros
                        (println begin)
                        ~...@body
                        (println end))))

(defmacro display-local-bindings []
  `(do ~@(map (fn [x#] (list 'println  [`'~x# x#])) (keys &env))))

(sym-macro
 (let [x 10]
   (display-local-bindings)))


the above form is not passing the correct &env variable to the nested macros
.. It is turning out to be nil. The above code just prints

:begin
:end

while

(let [x 10]
  (display-local-bindings))

prints

[x 10]

I was expecting the code

(sym-macro
 (let [x 10]
   (display-local-bindings)))

to print

:begin
[x 10]
:end

but this is not happening since the &env variable that is being passed to
(display-local-bindings) is nil when called inside a sym-macro
can somebody help me understand this.

Thanks,
Sunil.

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