June 15, 2015

With the latest ClojureScript, a def evaluated in the REPL results in a Var. But, you may miss the JavaScript that you have become accustomed to seeing for defn forms.

You could opt out of this new feature by setting the REPL option :def-emits-var to false. Alternatively, in a pinch, you can always deref a function Var in order to see its non-readable form, which happens to include its JavaScript.

But there's existed a REPL option all along that does exactly what you want, if your desire is to see the JavaScript for all forms entered in the REPL: :repl-verbose true.

The nice thing about :repl-verbose is that it is not overly verbose. In particular, it does not print the incidental JavaScript associated with maintaining *1, *e, etc., nor the additional JavaScript that is employed to cause def forms to emit Vars. It just shows you the logical equivalent of the JavaScript that is being evaluated in your JavaScript environment.

With :repl-verbose turned on, here is an example what you would see when defining a function:

cljs.user=> (defn sq [x] (* x x))
cljs.user.sq = (function cljs$user$sq(x){
return (x * x);

And, as a bonus, this lets you see the JavaScript for all forms, not just those associated with function definitions:

cljs.user=> (let [x 1] (inc x))
(function (){var x = (1);
return (x + (1));

It also gives insight into the JavaScript being executed related to the Google Closure dependency management:

cljs.user=> (ns hello.core)

Hope this helps!

Tags: ClojureScript