Multi-Form ClojureScript REPL
An update to the ClojureScript REPL has arrived, supporting multiple forms on a line.
Previously, only the first readable form would be evaluated:
cljs.user=> (+ 1 2) (str "a" "b") :hi
3
In the Clojure REPL, each is evaluated in sequence:
user=> (+ 1 2) (str "a" "b") :hi
3
"ab"
:hi
The difference has been addressed with the latest ClojureScript release, 1.9.542.
This fixes an issue where text after the first form was not properly handled. So, 1]
now properly produces an “Unmatched delimiter” diagnostic. Additionally, it is now possible to type :foo [
, hit return, and then type 2]
.
What’s the big deal?
Let’s say you pasted this code and hit return:
(def a 1)
(def b 2)
(def c (+ a b))
c
Previously, the first form (def a 1)
would be evaluated and then an attempt to evaluate c
would result in a “Use of undeclared Var” diagnostic.
With the fix, all forms are evaluated and you get the expected 3
. This makes it possible to freely paste code into a ClojureScript REPL without having to paste each form individually!