
On Sun, Aug 3, 2014 at 3:08 PM, Brandon Allbery
On Sun, Aug 3, 2014 at 2:43 PM, Elliot Robinson < elliot.robinson@argiopetech.com> wrote:
On Sat, Aug 2, 2014 at 3:54 AM, Donn Cave
wrote: Handles are for buffered I/O.
If this is the case, why is NoBuffering provided? Why does the documentation for Handle explicitly mention non-existent and zero-length buffers? If Handles are the standard cross-platform interface to buffered file IO, what is the standard cross-platform interface to unbuffered IO (output, specifically, since input is technically always at least 1 byte buffered)?
Handles provide a non-buffered interface, but often if you truly need unbuffered I/O you will be better suited by the platform's primitive operations; for which abstractions that enable some kind of reasonably platform independent interface may well cancel out the advantages of unbuffered I/O for those cases.
As a platform-specific optimization, this makes total sense. Most of the people who need this optimization know they need it. My fear is that offering "handles are for buffered I/O" (and statements like it) as general case rules leads to the "I'm new to <field> and I'm using System.Posix.IO for unbuffered IO because Handles aren't good for that, and now my program doesn't compile on <non-Posix OS>" ilk of Haskell-Cafe/SO questions. --- Elliot Robinson