Skip to content

Instantly share code, notes, and snippets.

@thheller
Created June 22, 2017 09:53
Show Gist options
  • Select an option

  • Save thheller/8b991971e200b821ee833733f34f533d to your computer and use it in GitHub Desktop.

Select an option

Save thheller/8b991971e200b821ee833733f34f533d to your computer and use it in GitHub Desktop.
mixing macros with cljs is ugly
(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))
@thheller

Copy link
Copy Markdown
Author

Note that the rules for self-hosted are completely different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment