[phobos] escaping FILE's buffering tyranny

s50 shinji.igarashi at gmail.com
Wed Sep 29 17:16:15 PDT 2010


If you choose the way looking at the actual definition of the
FILE structure, consider adding a query interface whether its
buffer is empty or not.

Then File can support non-blocking I/O to some extent.
For example, you can know whether reading from a fd would
block by calling select(). But it doesn't know FILE's buffer.
This is one of some reasons why Ruby1.9 abandoned the use
of C stdio, and why Ruby1.8 had been looking at fields of FILE.
Ruby uses user-thread, so non-blocking I/O is important for
I/O multiplexing. If anyone want to add non-blocking I/O
facilities to phobos, then probably the problem takes place
in D's case also.

If you choose another way, adding own buffering layer to
phobos, there is no problem.

Personally I don't like playing with FILE, but I understand
the benefits of the compatibility with C.


More information about the phobos mailing list