Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active February 13, 2019 13:44
Show Gist options
  • Save sogaiu/f24bf1b03665688ca7c3f8c42f3a71d7 to your computer and use it in GitHub Desktop.
Save sogaiu/f24bf1b03665688ca7c3f8c42f3a71d7 to your computer and use it in GitHub Desktop.
ideas for detecting which type of clojure (jvm, clr, js) is at remote end of the repl
; idea 1 - works if repl's read configured to support reader conditionals
#?(:clj :clj :cljr :cljr :cljs :cljs)
; idea 2 - may work - note that order is important below
; send this first
; if the result is non-nil, dealing with cljs, don't continue
(resolve '*clojurescript-version*)
; only send the following if the previous result was nil
; if the result is non-nil, dealing with clr, don't continue
(try
(import 'System.Object)
:cljr
(catch Exception _
nil))
; only send the following if the previous result was nil
; if the result is non-nil, dealing with jvm, don't continue
(try
(import 'java.lang.Object)
:clj
(catch Exception _
nil))
; if the previous was nil, don't know what we're dealing with
; N.B. trying to check jvm before clr may not work well as
; the clr repl doesn't appear to get along that well with the
; code to check for the jvm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment