ClojureScript REPL Changes

188 views
Skip to first unread message

Brenton

unread,
Oct 3, 2011, 10:11:16 AM10/3/11
to Clojure
Several improvements have been made to the ClojureScript REPL.

In ClojureScript, the method of printing output will be different for
each evaluation environment. There is now a var named *print-fn* in
cljs.core which will need to be explicitly set to a function that can
print in the target environment. If you would like to ignore all
printed output you could do this:

(set! *print-fn* (constantly nil))

The print function that you specify takes one argument, the value to
be printed. What you do with that value is totally up to you and your
environment. Sane defaults are set when running the REPL with Rhino or
the browser.

We are now using Rhino version 1.7R3 instead of whatever version of
Rhino is bundled with Java. This provides the following benefits:

* better error messages
* nice JavaScript stacktraces
* it's faster
* it isn't tied to a particular VM (should fix the problems people
were seeing on OpenJDK)

You will need to rerun script/bootstrap to download the Rhino jar and
install it in your lib folder. Windows people will need to do this
manually.

http://www.mozilla.org/rhino/download.html

For the browser-connected REPL, we can now print to the REPL. This
means that the browser-connected REPL works exactly like an old-
fashioned Clojure REPL.

For example, you can now do this:

ClojureScript:cljs.user> (time (reduce + (range 1000)))
"Elapsed time: 222 msecs"
499500

If your application is printing things while running then this printed
output will be printed in the REPL. Of course, you can set the *print-
fn* to do whatever you like.

Finally, when using Chrome and Firefox for evaluation, you will now
see JavaScript stacktraces in the REPL.

If you have been using the browser-connected REPL then you will need
to delete the .repl folder before using the new changes.

David Nolen

unread,
Oct 3, 2011, 10:25:46 AM10/3/11
to clo...@googlegroups.com
I've been playing with the changes for the past few days. Huge improvement. Thanks for all this!

David


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply all
Reply to author
Forward
0 new messages