With .cljc and reader conditionals, the story for writing platform - spanning clojure has become pretty good, except for one blatantly missing piece: We don't have macros that can generate different code for different targets.
Reader tags don't help there, since they always expand for the environment the compiler runs in.
When dealing with macros in cljc, this problem comes up frequently, due to the practice of putting otherwise compatible namespaces under different names.
Right now, I identify three possible solutions an application developer can choose from:
1. perpetuate the namespace split, as seen in the core.* contrib macro namespaces
(that's not ideal for programs that commit to platform-independence)
2. push all the platform-dependency out into cljc functions
(that's not always feasible, e.g. when emitting go-blocks)
3. look at the &env implicit argument to dispatch for your target runtime
(that's relying on an obscure implementation detail)
To illustrate how I could see this working, I have defined a `defmacro*` macro, that looks at its &env and provides a platform dispatch, similar to reader conditionals [1]. This seems to work well for defining platform-spanning macros [2].
It's still not optimal, as one has to emit fully expanded namespaces for cljs because syntax-quote will still expand for clj, but at least this makes it possible to write such macros.
While composing this email, somebody posted a similar topic on the user mailing list [3], so the need for such facilities definitely is there.
Any thoughts on how this could be supported properly?