How can I detect within a clojure-lang script file whether the script is run on JVM version or CLR version?
Thanks in advance.
The tool to use here, are reader conditions: https://clojure.org/guides/reader_conditionals
... Reader conditionals are integrated into the Clojure reader, and don’t require any extra tooling beyond Clojure 1.7 or greater. To use reader conditionals, all you need is for your file to have a
.cljc
extension and to use Clojure 1.7 or ClojureScript 0.0-3196 or higher ...... The standard reader conditional behaves similarly to a traditional
cond
. The syntax for usage is#?
and looks like:#?(:clj (Clojure expression) :cljs (ClojureScript expression) :cljr (Clojure CLR expression) :default (fallthrough expression))
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