there're three buffer mode in unix, line buffered, full buffered and no
buffered, if the output is terminal then it's default to line buffered.
That means it buffer the output until '\n' occurs, you can force output via
flush.

Thanks,
Di Xu


2014-04-10 19:30 GMT+08:00 Cecil Westerhof <cldwester...@gmail.com>:

> 2014-04-10 12:52 GMT+02:00 Kevin Ilchmann Jørgensen <kijm...@gmail.com>:
>
> I believe this is how the terminal behave. You can force an
>> (clojure.core/flush)
>>
>
> But why does println not behave this way?
>
> I think I stick to println for the moment.
>
>
> On Thu, Apr 10, 2014 at 12:34 PM, Cecil Westerhof 
> <cldwester...@gmail.com>wrote:
>>
>>> I have the following simple program:
>>>     (def time-format (new java.text.SimpleDateFormat "hh:mm:ss"))
>>>
>>>     (defn now []
>>>       (new java.util.GregorianCalendar))
>>>
>>>     (defn give-message [message]
>>>       (printf "%s: %s\n" (. time-format format (. (now) getTime))
>>> message))
>>>
>>>     (give-message "Start")
>>>     (doseq [i (range 1 100000001)]
>>>            (let [val (Math/sqrt i)
>>>                 diff (Math/abs (- (Math/pow val 2) (* val val)))]
>>>                 (when-not (< diff 1.5E-8)
>>>                   (println (format "Different for %d (%e)" i diff)))))
>>>     (give-message "Stop")
>>>
>>> It does what it should, but I have a little problem with it: the output
>>> of give-message is only showed after terminating the program. Why is that?
>>>
>>> When changing give-message to:
>>>     (defn give-message [message]
>>>       (println (format "%s: %s" (. time-format format (. (now) getTime))
>>> message)))
>>>
>>> the output is shown immediately.
>>>
>>
> --
> Cecil Westerhof
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@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+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to