reddit discussion on replacing Python in 0install

Denis Koroskin 2korden at gmail.com
Tue Jun 11 14:36:24 PDT 2013


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.

While it doesn't cover a case where file descriptor becomes 
non-writable during the program lifetime, it covers the most 
common case of file descriptor not being writable at all.


More information about the Digitalmars-d mailing list