Created
November 26, 2010 04:53
-
-
Save sunilnandihalli/716293 to your computer and use it in GitHub Desktop.
a small example demonstrating the problem with symbol macros..
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns symbol-macro-problem | |
(:require [clojure.contrib.macro-utils :as m])) | |
(defmacro sym-macro [& body] | |
`(m/symbol-macrolet [begin :begin | |
end :end] | |
(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))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment