Greetings,<div><br></div><div>I noticed a different behaviour when using stdout.writeln() instead of writeln() in FreeBSD.</div><div>It seems that the first issues an explicit fflush each time it's called, while the latter doesn't.</div>
<div>This makes a difference at least in FreeBSD, where writes to the stdout are line-buffered </div><div>by the system only when the destination is a real console and not, for example, a file or a pipe.</div><div>In that case, one call will write the output one line at time, while the other won't.</div>
<div><br></div><div>It can be easily seen with the following trivial program, if you pipe it's output to "cat".</div><div>(using dmd 2.0.47 under FreeBSD 8.1)</div><div><br></div><div><div>module hello;</div>
<div><br></div><div>import std.stdio;</div><div>import core.sys.posix.unistd;</div><div><br></div><div>void main()</div><div>{</div><div> foreach(n;0..100_000)</div><div> {</div><div> writeln("Hello World!");</div>
<div> // stdout.writeln("Hello World!");</div><div> sleep(1);</div><div> }</div><div>}</div><div><br></div><div><br></div><div>I'm not sure which of the two behaviours is the right one (the C version of the program using printf behaves like writeln, the C++ version using cout behaves like stout.writeln...)</div>
</div><div><br></div><div><br></div><div>bye,</div><div>Marco</div><div><br></div>