Minor std.stdio.File.ByLine rant

Steven Schveighoffer schveiguy at yahoo.com
Thu Feb 27 04:55:59 PST 2014


On Wed, 26 Feb 2014 18:44:10 -0500, H. S. Teoh <hsteoh at quickfur.ath.cx>  
wrote:

> First of all, the way ByLine works is kinda tricky, even in the previous
> releases. The underlying cause is that at least on Posix, the underlying
> C feof() call doesn't actually tell you whether you're really at EOF
> until you try to read something from the file descriptor.

This is not a posix problem, it's a general stream problem.

A stream is not at EOF until the write end is closed. Until then, you  
cannot know whether it's empty until you read and don't get anything back.  
Even if a primitive existed that allowed you to tell whether the write end  
was closed, you can race this against the other process closing it's write  
end.

I think the correct solution is to block on the first front call. We may  
be able to do this without storing an additional variable.

-Steve


More information about the Digitalmars-d mailing list