Created
October 7, 2014 20:38
-
-
Save nahuel/a07db3003ad22bda17a0 to your computer and use it in GitHub Desktop.
taking care on macroexpansion order when using *ns* in macros
This file contains hidden or 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 c) | |
(defmacro print-ns [] (println [:c *ns*])) | |
(ns b) | |
(defmacro print-ns [] (c/print-ns)) | |
;;=> prints [:c #<Namespace b>] when c/print-ns is expanded | |
(b/print-ns) | |
;;=> nothing printed, c/print-ns already macroexpanded (and println executed) on the b/print-ns defmacro | |
(ns a) | |
(c/print-ns) | |
;;=> prints [:c #<Namespace a>] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment