simpler I/O buffering [was: RE: An IO Question from a Newbie]

Simon Marlow simonmar at
Tue Sep 16 15:32:45 EDT 2003

> Writing a sequence of characters across the interface I'm 
> proposing is a 
> request by the writing program for those characters to appear 
> at their 
> destination "soon".  Ideally, "soon" would be "immediately"; 
> however, the 
> characters' appearance may deliberately be delayed ("buffered"), for 
> efficiency, as long as such delay is "unobtrusive" to a human 
> user of the 
> program.  Buffering timeouts would depend on the device; for 
> a terminal, 
> perhaps 50-100 ms would be appropriate.  Such an interval 
> would tend not 
> to be noticeable to a human user but would be long enough to 
> effectively 
> collect, say, an entire line of output for output "in one 
> piece".  The use 
> of a reasonable timeout would avoid the confusing behavior where a 
> newline-less prompt doesn't appear until the prompted data is entered.

So, let me see if I've understood: the situation would be exactly as
now, except that the buffer automatically gets flushed if it stays
non-empty for more than a certain time interval.

I don't think I like it:  whatever time interval you choose will be too
long.  If you're doing communication with another program, for example,
you really don't want to have the dialog stalled for 100ms doing
nothing.  Sure, you could insert a flush, but only a programmer
knowledgeable about buffering will know to do that, or a programmer who
has debugged the program in detail to find out why it is sitting idle
most of the time.

So, in the end the programmer still needs to know about buffering.  I'd
prefer it if the program didn't work at all when the flush is missing,
because it tells you immediately that something is wrong.


More information about the Haskell-Cafe mailing list