While clojure and clojurescript features are basically the same (apart from obvious differences), macros are not. When I want a macro in clojurescript I have to write it in clojure and require it with require-macros. Is that a technical limitation of javascript or just a design decision? Why can't both be the same?
From ClojureScript: Up and Running by Stuart Sierra and Luker VanderHart, page 69:
Macros are applied during the compilation process. They do not exist at runtime. Because the ClojureScript compiler is implemented in Clojure, ClojureScript macros must be written in Clojure, not ClojureScript. Fortunately, Clojure and ClojureScript are almost identical when it comes to manipulating data structures, so switching between the two languages is not difficult.
What that means is that macro code gets executed in Clojure world and not in the browser, so it must be written in plain Clojure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With