philipbohun.com

Glojure by Example: Reader Conditionals

A reader conditional keeps one branch of a form for the platform that is reading the file. Glojure defines the feature :glj. JVM Clojure defines :clj. Files that must run on both can use .cljc. Use .glj when the file calls Go.

(println #?(:glj "running on glojure"
            :clj "running on clojure"
            :default "elsewhere"))

The reader keeps the :glj branch and discards the rest.

$ glj reader-conditionals.glj
running on glojure

Next example: Embedding.