Share your thoughts in the 2021 Clojure Community Survey!

Welcome! Please see the About page for a little more info on how this works.

+1 vote
in ClojureScript by
edited by

update: I have raised this as an issue:

I am trying to write a library which provides a set of tagged literals (and their reader fns) for consumption from both clojure and clojurescript.





(defn bar [x]
  #?(:clj (str "hello! " x)
     :cljs (clj->js x)))

cmd line:

clj --main cljs.main -e "(println #foo/bar \"world\")"

prints "hello, world"

clojurescript compiles+executes the :clj branch in the bar reader fn - as far as I can see there is no way to execute cljs code in a reader. I have also tried having a my/project/foo.cljs (ie cljs only) file - but this doesn't work either.

I have tried using a workaround where the reader function returns a form, see and this works ok, except that now those reader functions don't work when being used with clojure (e.g. clojure.core/read-string) - see


Please log in or register to answer this question.