I wanted to enumerate the macros of cljs.core
in ClojureScript. In general, it would not be needed for everyday ClojureScrit programming but I need it to author my debux library.
At first, I asked a question about this problem in Google Clojure Group but got no answers.
I decided to find the way by myself and finally found a way to enumerate the macros of cljs.core
in Clojure REPL, so I want to share the exprerience with others here.
The functions of cljs.core
are defined in src/main/cljs/cljs/core.cljs
and the macros of cljs.core
are defined in src/main/clojure/cljs/core.cljc
. So you have to evaluate the src/main/clojure/cljs/core.cljc
file in Clojure REPL, not in ClojureScript REPL, to get a list of the macros of cljs.core
.
I will explain the way based on emacs CIDER environment.
-
Download the ClojureScript source from https://github.com/clojure/clojurescript repository.
-
Unzip the source and open the
src/main/clojure/cljs/core.cljc
file in an emacs buffer. -
Press
C-c C-j
to launch the Clojure REPL. -
Press
C-c C-k
to evaluate the buffer’s file. -
Go to the Clojure REPL window and evaluate the following code and you can get the list of
cljs.core
mactos.
;; As of ClojureScript 1.10.238
user> (->> (ns-publics 'cljs.core)
vals
(filter #(get (meta %) :macro))
(map str)
sort
clojure.pprint/pprint)
("#'cljs.core/*"
"#'cljs.core/+"
"#'cljs.core/-"
"#'cljs.core/->"
"#'cljs.core/->>"
"#'cljs.core/.."
"#'cljs.core//"
"#'cljs.core/<"
"#'cljs.core/<="
"#'cljs.core/=="
"#'cljs.core/>"
"#'cljs.core/>="
"#'cljs.core/aget"
"#'cljs.core/alength"
"#'cljs.core/amap"
"#'cljs.core/and"
"#'cljs.core/areduce"
"#'cljs.core/array"
"#'cljs.core/array-map"
"#'cljs.core/as->"
"#'cljs.core/aset"
"#'cljs.core/assert"
"#'cljs.core/binding"
"#'cljs.core/bit-and"
"#'cljs.core/bit-and-not"
"#'cljs.core/bit-clear"
"#'cljs.core/bit-flip"
"#'cljs.core/bit-not"
"#'cljs.core/bit-or"
"#'cljs.core/bit-set"
"#'cljs.core/bit-shift-left"
"#'cljs.core/bit-shift-right"
"#'cljs.core/bit-shift-right-zero-fill"
"#'cljs.core/bit-test"
"#'cljs.core/bit-xor"
"#'cljs.core/bitpos"
"#'cljs.core/byte"
"#'cljs.core/caching-hash"
"#'cljs.core/case"
"#'cljs.core/coercive-="
"#'cljs.core/coercive-boolean"
"#'cljs.core/coercive-not"
"#'cljs.core/coercive-not="
"#'cljs.core/comment"
"#'cljs.core/cond"
"#'cljs.core/cond->"
"#'cljs.core/cond->>"
"#'cljs.core/condp"
"#'cljs.core/copy-arguments"
"#'cljs.core/dec"
"#'cljs.core/declare"
"#'cljs.core/defmacro"
"#'cljs.core/defmethod"
"#'cljs.core/defmulti"
"#'cljs.core/defn"
"#'cljs.core/defn-"
"#'cljs.core/defonce"
"#'cljs.core/defprotocol"
"#'cljs.core/defrecord"
"#'cljs.core/deftype"
"#'cljs.core/delay"
"#'cljs.core/divide"
"#'cljs.core/doseq"
"#'cljs.core/dotimes"
"#'cljs.core/doto"
"#'cljs.core/double"
"#'cljs.core/es6-iterable"
"#'cljs.core/exists?"
"#'cljs.core/extend-protocol"
"#'cljs.core/extend-type"
"#'cljs.core/false?"
"#'cljs.core/float"
"#'cljs.core/fn"
"#'cljs.core/for"
"#'cljs.core/gen-apply-to"
"#'cljs.core/gen-apply-to-simple"
"#'cljs.core/goog-define"
"#'cljs.core/hash-map"
"#'cljs.core/hash-set"
"#'cljs.core/identical?"
"#'cljs.core/if-let"
"#'cljs.core/if-not"
"#'cljs.core/if-some"
"#'cljs.core/implements?"
"#'cljs.core/import"
"#'cljs.core/import-macros"
"#'cljs.core/inc"
"#'cljs.core/instance?"
"#'cljs.core/int"
"#'cljs.core/js-arguments"
"#'cljs.core/js-comment"
"#'cljs.core/js-debugger"
"#'cljs.core/js-delete"
"#'cljs.core/js-in"
"#'cljs.core/js-inline-comment"
"#'cljs.core/js-mod"
"#'cljs.core/js-obj"
"#'cljs.core/js-str"
"#'cljs.core/keyword?"
"#'cljs.core/lazy-cat"
"#'cljs.core/lazy-seq"
"#'cljs.core/let"
"#'cljs.core/letfn"
"#'cljs.core/list"
"#'cljs.core/load-file*"
"#'cljs.core/locking"
"#'cljs.core/loop"
"#'cljs.core/macroexpand"
"#'cljs.core/macroexpand-1"
"#'cljs.core/make-array"
"#'cljs.core/mask"
"#'cljs.core/max"
"#'cljs.core/memfn"
"#'cljs.core/min"
"#'cljs.core/neg?"
"#'cljs.core/nil?"
"#'cljs.core/ns-imports"
"#'cljs.core/ns-interns"
"#'cljs.core/ns-publics"
"#'cljs.core/ns-unmap"
"#'cljs.core/number?"
"#'cljs.core/or"
"#'cljs.core/pos?"
"#'cljs.core/refer-clojure"
"#'cljs.core/reify"
"#'cljs.core/require"
"#'cljs.core/require-macros"
"#'cljs.core/resolve"
"#'cljs.core/satisfies?"
"#'cljs.core/short"
"#'cljs.core/simple-benchmark"
"#'cljs.core/some->"
"#'cljs.core/some->>"
"#'cljs.core/some?"
"#'cljs.core/specify"
"#'cljs.core/specify!"
"#'cljs.core/str"
"#'cljs.core/string?"
"#'cljs.core/symbol?"
"#'cljs.core/this-as"
"#'cljs.core/time"
"#'cljs.core/true?"
"#'cljs.core/truth_"
"#'cljs.core/unchecked-add"
"#'cljs.core/unchecked-add-int"
"#'cljs.core/unchecked-byte"
"#'cljs.core/unchecked-char"
"#'cljs.core/unchecked-dec"
"#'cljs.core/unchecked-dec-int"
"#'cljs.core/unchecked-divide-int"
"#'cljs.core/unchecked-double"
"#'cljs.core/unchecked-float"
"#'cljs.core/unchecked-get"
"#'cljs.core/unchecked-inc"
"#'cljs.core/unchecked-inc-int"
"#'cljs.core/unchecked-multiply"
"#'cljs.core/unchecked-multiply-int"
"#'cljs.core/unchecked-negate"
"#'cljs.core/unchecked-negate-int"
"#'cljs.core/unchecked-remainder-int"
"#'cljs.core/unchecked-set"
"#'cljs.core/unchecked-short"
"#'cljs.core/unchecked-subtract"
"#'cljs.core/unchecked-subtract-int"
"#'cljs.core/undefined?"
"#'cljs.core/unsafe-bit-and"
"#'cljs.core/unsafe-cast"
"#'cljs.core/unsigned-bit-shift-right"
"#'cljs.core/use"
"#'cljs.core/use-macros"
"#'cljs.core/vector"
"#'cljs.core/vswap!"
"#'cljs.core/when"
"#'cljs.core/when-first"
"#'cljs.core/when-let"
"#'cljs.core/when-not"
"#'cljs.core/when-some"
"#'cljs.core/while"
"#'cljs.core/with-out-str"
"#'cljs.core/with-redefs"
"#'cljs.core/zero?")
nil
user>