Is it possible to share macros between cljs and cls ?
opened this issue · comments
I've trying to port a debug macro -- https://github.com/harsha-mudi/dbg
cljx didn't apply cljs rules to a .clj file initially
cljx runs long before either Clojure or ClojureScript macroexpansion, and so cannot be used to control the forms produced by macros.
My preferred method for writing portable macros is to check &env
, which has a different value in ClojureScript and Clojure. See https://bitbucket.org/cemerick/cljs-sanity/src/9dced70e72957146c418ed4465703aad99ec1496/src/clj/cemerick/cljs/macro.clj?at=master, which is used in https://github.com/QuiltProject/splice/blob/master/src/clj/cemerick/splice/memory/indexing.clj
>.< I must be going blind ! My typos / sentence is consistently increasing.
@cemerick
Thx for the tip ! Will try it.
The Readme currently states,
Also, note that cljx has no effect on code produced by macros. Macroexpansion occurs long after cljx touches your code.
It could be followed by some warning on porting macros, and maybe a mention of your &env hack ?