Skip to content

Instantly share code, notes, and snippets.

@nahuel
Created October 7, 2014 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahuel/a07db3003ad22bda17a0 to your computer and use it in GitHub Desktop.
Save nahuel/a07db3003ad22bda17a0 to your computer and use it in GitHub Desktop.
taking care on macroexpansion order when using *ns* in macros
(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