Improved Function Printing

July 29, 2017

A change landed in the ClojureScript 1.9.854 release which supresses the printing of JavaScript associated with function bodies.




Previously, if you printed a function, you would see the associated JavaScript implementation. Here is an example:

cljs.user=> (fn [] (inc 3))
#object[ret__6185__auto__ "function (){
return ((3) + (1));
}"]

Now, in ClojureScript 1.9.854, the default is to print a much more compact representation:

cljs.user=> (fn [] (inc 3))
#object[ret__6185__auto__]

In this example, you see a synthetic name, but for functions def’d and associated with Vars, you see a bit more useful info:

cljs.user=> map
#object[cljs$core$map]

If you'd like to see the JavaScript, you can control this via a new *print-fn-bodies* Var. Doing the following at the REPL will cause printing to behave as it did previously:

 (set! *print-fn-bodies* true)

And, if you'd like to see all of the JavaScript at the REPL, there is the :repl-verbose option. (I wrote a little about :repl-verbose in See JS in CLJS REPL.)

Tags: ClojureScript