On 6/11/2013 8:55 PM, Steven Schveighoffer wrote:
On Tue, 11 Jun 2013 23:42:33 -0400, Walter Bright <newshou...@digitalmars.com>
wrote:

On 6/11/2013 7:07 PM, Steven Schveighoffer wrote:
On Tue, 11 Jun 2013 17:36:24 -0400, Denis Koroskin <2kor...@gmail.com> wrote:

On Tuesday, 11 June 2013 at 16:50:50 UTC, Andrei Alexandrescu wrote:
On 6/11/13 11:57 AM, Steven Schveighoffer wrote:
This code DOES fail:

import std.stdio;

int main()
{
writeln("hello");
std.stdio.stdout.flush();
return 0;
}

Ah, I suspected so. (At a point in D's history writeln() did do a flush;
people wanted to eliminate it for efficiency reasons.)

We could introduce a flush() with throw in std.stdiobase.


Andrei

The best solution would be for writeln() to throw on use, and I think it's
fairly easy to implement: just flush once after using the file descriptor for
the first time, and throw if it fails.

This is a good idea.

I think you meant "just flush once after using the FILE * for the first time"

I think it's a bad idea, it'll muck up the buffering (i.e. make it slower).

Note, it's only done once, the very first time anything is written.  The rest of
the time, flushing follows normal procedure.

In effect, the first write confirms the FD is valid, then all writes after
assume it stays valid.

I don't agree. Buffering is often done on page size boundaries - throwing out a random number of characters and then flushing will get it all wonky.

Reply via email to