In Clojure, you can disable asserts by setting the
*assert* var to
false. Once set, this affects any newly compiled code which uses the
assert macro. For example, normally
(macroexpand '(assert (= 1 2) "hi"))
yields (reformatted for whitespace):
(if (= 1 2) nil (do (throw (new java.lang.AssertionError (clojure.core/str "Assert failed: " "hi" "\n" (clojure.core/pr-str (quote (= 1 2))))))))
But if you first set
false, then the
assert macro will expand to
In ClojureScript, on the other hand, with macros being expanded via Clojure, setting
*assert* (either at the REPL or in your ClojureScript code) cannot affect the macroexpansion. Instead, you must rely on the
:elide-asserts compiler option.
But in bootstrap ClojureScript, since macros are compiled as ClojureScript, in the same environment with the code, setting
*assert* in self-hosted environments works just as it does in Clojure.