Last active
November 9, 2016 14:29
-
-
Save mhuebert/360fa2da97adac7756605b2d1438f753 to your computer and use it in GitHub Desktop.
Macros that require macros, in ClojureScript. Remember, in your .clj file: use `:require` with `:include-macros true`
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 app.x | |
(:require [app.y :refer [y-macro] :include-macros true])) | |
(defmacro x-macro [& args] | |
(y-macro args)) | |
;; how can we use macros from one .clj namespace in another .clj namespace? | |
;; take a close look at the :require statement above. Two important points: | |
;; - it must say :require, not :require-macros | |
;; - it must say `:include-macros true` |
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 app.x | |
(:require-macros app.x)) | |
;; cljs namespace requires same-name clj namespace |
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 app.y) | |
(defmacro y-macro [& args] | |
`[~@args]) | |
;; this is a macro that I would like to use from within another macro namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment