Clojure: *out* vs System/out
<p>I'm trying to translate a small console program I wrote in Java into Clojure, but I'm having a little trouble figuring out the difference between Clojure's standard <code>*out*</code> var and the object at <code>System/out</code>. I was under the impression that they were the same thing, but when during my testing they seem to be different.</p>

<p>In my program I prompt the user to enter a number, and I want the prompt and input text to be on the same line. In Java, I printed the prompt with <code>System.out.print()</code> and then a Scanner read the input.</p>

<p>The following was my first attempt at something similar in Clojure. Though the <code>print</code> function seems like it should fire before the <code>read-line</code>, it immediately blocks on input and prints everything after in a jumbled mess:</p>

<pre><code>(defn inp1 []
    (print "Enter your input: ")
    (let [in (read-line)]
        (println "Your input is: " in)))
</code></pre>

<p>The following was my next attempt, using <code>*out*</code>. It suffers from the same problem as the function above:</p>

<pre><code>(defn inp2 []
    (.print *out* "Enter input: ")
    (let [i (read-line)]
        (println "You entered: " i)))
</code></pre>

<p>On my third try, I finally got it to work by using <code>System/out</code> directly:</p>

<pre><code>(defn inp3 []
    (let [o System/out]
        (.print o "Enter input: ")
        (let [i (read-line)]
            (println "You entered: " i))))
</code></pre>

<p>I'm glad I finally got it to work, but I'm deeply confused as to why the third one works the way I want when the first two don't. Why do the first two block immediately? Can anyone shed some light on this?</p>