Very minor problem in the REPL

1 view
Skip to first unread message

AlamedaMike

unread,
Jul 17, 2009, 9:05:48 AM7/17/09
to Clojure
This is so trivial from a technical standpoint I'm embarrassed to
mention it. The REPL is accepting more than one sexp on a line and
then generating output for all of them in an unusual fashion. In the
following, all text after the first line is generated by clojure
(except for the comment, of course).

user=> 34,6
34
user=> 6

;-----------------------------
user=> (* 7 8) (+ 3 4) (* 3 2)
56
user=> 7
user=> 6
user=>

;-----------------------------
user=> 454 65
454
user=> 65

;-----------------------------
user=> (* 7 8) 3423
56
user=> 3423

;-----------------------------
user=> (* 7 8) 3423
56
user=> 3423
user=>

As I say, technically very trivial, but it violates the principal of
least surprise (for me). I bring it up only because of reasons of
broader acceptance by the business community. I know how some of them
think, and even trivial stuff like this will make them think (it ain't
solid yet). As the head of a Swedish airline once said, "Passengers
think that because there are coffee stains under the foldout tray, we
don't do our engine maintenance."

I will now slink away in shame...

Andrew Wagner

unread,
Jul 17, 2009, 9:07:58 AM7/17/09
to clo...@googlegroups.com
Sounds like a good application of the broken window principle to me.

Stephen C. Gilardi

unread,
Jul 17, 2009, 11:31:03 AM7/17/09
to clo...@googlegroups.com

On Jul 17, 2009, at 9:05 AM, AlamedaMike wrote:

> As I say, technically very trivial, but it violates the principal of
> least surprise (for me). I bring it up only because of reasons of
> broader acceptance by the business community. I know how some of them
> think, and even trivial stuff like this will make them think (it ain't
> solid yet). As the head of a Swedish airline once said, "Passengers

It looks like somehow you're seeing a very old REPL or it's not the
default REPL you get from launching Clojure via clojure.main. Here's
what I get from both Clojure 1.0 and the current git HEAD:

user=> 34,6
34
6


user=> (* 7 8) (+ 3 4) (* 3 2)
56

7
6
user=> 454 65
454
65


user=> (* 7 8) 3423
56

3423


user=> (* 7 8) 3423
56

3423
user=>

The command line I used to launch the REPL for the test is (from
within the clojure directory):

java -cp clojure.jar clojure.main.

I didn't like the behavior you were noting either. When I rewrote the
REPL in Clojure, I made it work as shown above. Do you think the
Swedes would approve?

--Steve

John Harrop

unread,
Jul 17, 2009, 3:20:12 PM7/17/09
to clo...@googlegroups.com
On Fri, Jul 17, 2009 at 11:31 AM, Stephen C. Gilardi <sque...@mac.com> wrote:
It looks like somehow you're seeing a very old REPL or it's not the default REPL you get from launching Clojure via clojure.main. 

I can confirm the described behavior for the enclojure REPL. 

ronen

unread,
Jul 25, 2009, 12:48:51 PM7/25/09
to Clojure
Iv stumbled this also when using Threads, (http://
javadevelopmentforthemasses.blogspot.com/2009/07/easiest-singleton-
around.html)

user=> (defn singleton-factory []
(println "creating object")
(+ 1 2))
user=> (use 'clojure.contrib.singleton)
nil
user=> (def t-singleton (per-thread-singleton singleton-factory))
#'user/t-singleton
user=> (defn use-twice [] (+ 1 (t-singleton)) (+ 1 (t-singleton)))
#'user/use-twice
user=> (. (Thread. use-twice) start)
nil
user=> creating object ; REPL prints on the wrong line

Stuart Sierra

unread,
Jul 25, 2009, 1:14:52 PM7/25/09
to Clojure
That's a general problem with multiple threads printing to the same
stream, and not something that can be easily avoided.
-Stuart
Reply all
Reply to author
Forward
0 new messages