buffering of (print)

Started by Dmi, March 12, 2008, 03:11:51 AM

Previous topic - Next topic

Dmi

Hi, Lutz!



Just discover that
(while true (print ".") (sleep 1000))
started in command prompt shows all the output only after execution is finished.

Often this is not useful.

If this is a new behavior, then something like (flush), or, better, the output buffer configuration for particular handle, like in perl,  will be a good addition.
WBR, Dmi

Lutz

#1
On Unix Mac OS X you can import fflush()


> (import "libc.dylib" "fflush")
fflush <948F88C7>
> (while true (print ".") (fflush 0) (sleep 200))
................................................^Creceived SIGINT - in function sleep
(c)ontinue, (d)ebug, e(x)it, (r)eset:r
>


The SIGINT was caused by hitting Ctrl-C. The above is on Mac OS X. On Linux you would use: libc.so. On Win32 something else?



ps: output is also forced with line-feeds

Dmi

#2
Thanks.
WBR, Dmi

Lutz

#3
... and you can also use 'write-buffer' on stdout and don't need to flush:


> (while true (write-buffer 0 ".") (sleep 200))
..................^Creceived SIGINT - in function sleep
(c)ontinue, (d)ebug, e(x)it, (r)eset:x
~>

Dmi

#4
oh! write-buffer is sufficient! thanks again!
WBR, Dmi