In the REPL return vars after defs


We don't want to emit these in during normal compilation. However it's nice to unify the REPL experience with Clojure's. Currently we just display the value of the def. REPLs could set a :repl build flag which is checked by the emit* :def case. For this to work the analyzer should compile the var AST and include it in the def AST so the compiler can optionally use it.




Mike Fikes
June 11, 2015, 3:38 PM

IRC Feedback from David:

Mike Fikes
June 11, 2015, 7:18 PM

CLJS-934-v4.patch makes two primary revisions:

  1. Introduces a REPL option :def-emits-vars which defaults to true and which is conveyed into the analysis/compilation environment by cljs.repl

  2. The var AST is no longer unconditionally included in the def AST and the analyzer instead looks for :def-emits-vars

Notably, this patch doesn't go so far as to treat :def-emits-vars additionally as a build-affecting compiler option. Rationale: It affects AST generation. It also seems currently unlikely that there would be desire to actually support compiling code with this enabled.

Mike Fikes
June 11, 2015, 7:43 PM

One bit of follow-up with respect to CLJS-934-v4.patch. I failed to notice that the JavaScript is also generated and displayed if :repl-verbose true is set.

Patch 4 REPL interactions look like this if :repl-verbose is set:

In the above, in particular, you don't see the additional var emission JavaScript which is actually included when producing wrap-js, which does *1 *2 *3 *e, etc., as well.

If the purpose of :repl-verbose is to simply help the end user in seeing the "logical" JavaScript that corresponds to forms, then the above is great, but if it is for truly diagnosing low-level things, then including this extra var stuff is possible and would look like the below. (I'm suspecting it is the former and not the latter, as *1 and friends are omitted when :repo-verbose is true, but an additional patch could be created which produces the output below.)

David Nolen
June 12, 2015, 1:54 PM

The approach in patch 4 is the right one. When any of the debugging modes are engaged we don't want to generate the "extra" stuff.

David Nolen
June 12, 2015, 3:44 PM




David Nolen