Evaluation order of expressions with read-line in Clojure -
this question has reply here:
clojure - side effects happening out of order 2 answersi running next code snippet:
(print "enter something:") (let [entry (read-line)] (println "you entered" entry) )
i expect see next type of interaction:
enter something:abc entered abc
instead, see:
abc come in something:you entered abc
why user input requested first, though print comes first in code? tried googling around, can tell, evaluation order should expect coming java/python background. expected behavior of code?
just pasting comment on real answer.
java flushes stdout on \n
. need forcibly flush buffer if want output (read consistently, have no command on it) have written in example, or add together \n
using (println ...)
or (print ... "\n")
.
see: will java's system.out.print() buffer forever until println()?
clojure
No comments:
Post a Comment