Macros in ClojureScript
The distinction between compile time and runtime is perhaps the most important concept to grasp when learning about macros. Before going further into the consequences of this distinction, it's worth looking at how it affects macros in ClojureScript, where compilation and execution have a slightly more complex relationship than they do in JVM Clojure.
ClojureScript runs in a JavaScript runtime, like the browser or Node.js. This is possible because ClojureScript code is first compiled by the ClojureScript compiler, which is a program written in Clojure and runs on the JVM. This means that ClojureScript programs, once they're compiled and running, no longer have access to the compilation phase.
This has several consequences for working with macros in ClojureScript, the most important of which is that ClojureScript macros cannot be defined in .cljs
files
alongside other ClojureScript code. Instead, they are defined in separate files with either...