Created
June 22, 2017 09:53
-
-
Save thheller/8b991971e200b821ee833733f34f533d to your computer and use it in GitHub Desktop.
mixing macros with cljs is ugly
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 demo.mixed | |
| #?(:cljs (:require-macros [demo.mixed]))) | |
| ;; CLJ cannot compile JS only code | |
| (defn cljs-only [] | |
| (js/console.log "cljs-only doesn't compile in CLJ")) | |
| ;; so it needs to put into a reader conditional | |
| #?(:cljs | |
| (defn cljs-only [] | |
| (js/console.log "now CLJ is happy"))) | |
| ;; this will compile fine in CLJ and CLJS | |
| ;; so it does not need a reader conditional | |
| (defn this-is-shared [] | |
| :foo) | |
| ;; macros as CLJ only, so they also need to be inside areader conditional | |
| #?(:clj | |
| (defmacro hello-world [& args] | |
| :hello-world)) | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that the rules for self-hosted are completely different.