phobos / tango / ares

Frits van Bommel fvbommel at
Sat Feb 10 03:51:41 PST 2007

torhu wrote:
> Sean Kelly wrote:
>> That said, I believe that the default output format can be called via:
>> Stdout( a, b, c );
>> or the "whisper" syntax:
>> Stdout( a )( b )( c );
> One thing that surprised me when trying out this, was that the buffer is 
> never flushed automatically.  Not even when outputting a '\n'.  Not for 
> small outputs anyway.  I'm used to printf's unbuffered output, at least 
> on windows.  Stdout.formatln() does flush, so it might be safer to stick 
> with that than to risk forgetting to flush when doing some 'printf 
> debugging'.  Just a thought.
> (I know about .newline and .flush.)

For Cout and Stdout, .opCall with no arguments is equivalent to 
.flush(). It provides for a quite clean syntax to specify "please flush 
now". Not perfect but quite usable. I don't think there's way to 
determine, when using whisper syntax, when an appropriate time would be 
to flush except if explicitly requested.

On a related note, one of the things that bothers /me/ is that no flush 
is performed at the end of the program. That causes some or all of the 
output to be missing if you don't explicitly flush after the last output.
I'd suggest adding the following to
static ~this ()

That would fix it, I think.
(Well, I could probably write some code that maintains indirect 
references to Cout/Cerr from modules not importing, but 
above addition should fix it for *most* cases)

More information about the Digitalmars-d-learn mailing list