Flushing output with print()


#1

It seems that calling print (or puts) in ChaiScript will not flush output. How can I go about making it do so? Setting unitbuf on cout doesn’t seem to help.

Loving everything else about ChaiScript so far, it’s really great :smiley:


#2

Interesting point, I cannot think if a way to do that right now. If you are doing lots of io you don’t want the flush after every statement, but I can see wanting to a flush on demand, or have a flushing print statement.

You could expose your own flushing print statement, and I can think about a reasonable way to handle that in the stdlib.

Jason


#3

Yeah, that’s what I’m doing at the moment, exposing a new functing that is just cout << str << endl. But, it seems like it would make more sense for print() specifically to flush, as I imagine the majority of it’s usage is debugging.


#4

I actually only relatively recently changed it to not flush because a particular user was seeing HUGE performance issues on Windows with lots of output being written to the screen. Some platforms have a very large penalty for waiting for the flush.