reddit discussion on replacing Python in 0install

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Jun 12 13:41:03 PDT 2013


12-Jun-2013 22:36, Steven Schveighoffer пишет:
> On Wed, 12 Jun 2013 12:40:53 -0400, Walter Bright
...
> No, this is incorrect.  fflush is not called on subsequent writeln.
>
> Not only that, but we only have to do this on FILE * that were
> initialized with unknown file descriptors (such as
> stdin/stdout/stderr).  If we use fopen, you don't have to do this.
>

Steve, the only unchecked place right now is in the _last_ flush. Even 
if you flush on first call it won't help some other forms of errors 
(other then it's not writable to begin with). The only thing it will do 
is surprise certain kinds of applications that use fdopen with "passed 
in" sockets and whatnot. Basically a year later we'll see puzzled folks 
with strace printouts.

The only thing that's broken here is that C-runtime doesn't care for 
errors on file descriptors it flushes at termination.

Now since it's D we may as flush global files at end of main (in static 
dtor) while still in the "D world" then throw. This however leaves 
flushes on uncollected Files that were allocated with new or as a part 
of GC arrays. Given that these cases are bogus to begin with I'd say go 
ahead with

shared static ~this()
{
	stdout.flush();
	stderr.flush();
}


-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list