On 14-Sep-1999, Simon Peyton-Jones <[EMAIL PROTECTED]> wrote:
> > Suppose I want to read a file and write filtered contents back to it
> > (don't mind a backup).   [...explains why hGetContents doesn't work...]
> 
> An entirely reasonable question.  The semantics of lazy file
> reading in the Haskell98 Library Report is quite hard to understand,
> and seems to be oriented more towards easy implementation than
> easy use.  In particular, it would be very nice if:
> 
>       the semantics of hGetFileContents was just as if
>       the entire contents of the file was read instantaneously

I don't see how you can get those semantics and still remain lazy.
The only way I can see to implement that on e.g. Unix systems is
to actually read the whole file then and there.  In fact if
"instantaneously" is taken too literally, even that would not be
sufficient.

...
> I'm sure there was extensive discussion of this point when
> the I/O library was developed.  I don't know if there are any
> serious implementation difficulties with the semantics I suggest
> above.

Well, consider the case where the file being read is also being concurrently
modified by another process.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.


Reply via email to