[m-rev.] io__read_file_as_string (was: improve `_init.c' file creation)
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Dec 6 20:18:33 AEDT 2001
On 28-Nov-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> On 28-Nov-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > On 28-Nov-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > > > > + % XXX Why does `io__read_file_as_string' return a separate
> > > > > + % status and result, rather than an `io__res(string)'?
> > > >
> > > > The reason is to ensure that, in the case when some characters are
> > > > successfully read and then an I/O error occurs, the part of the file
> > > > that was successfully read can be returned.
> > >
> > > When is that behaviour useful?
> >
> > When the error is something such as EINTR.
> >
> > When implementing programs such as `cat', which should output all that
> > it successfully reads before reporting a read error.
>
> `io__read_file' is inappropriate for this kind of application
> because the size of the input is not bounded.
Well, perhaps not for the generic `cat' program,
but I can imagine a lot of cat-like utilities
(rot13, toupper, etc.) for which read_file_as_string
might well be appropriate, but for which the same principle
applies.
> > When the error occurs because the input file is `stdin',
> > and the user's dialup connection has just been disconnected
> > due to a Telstra fault. The data may be hard for the user
> > to reproduce, so the program should not just throw it away.
>
> Applications taking user input from stdin generally don't use
> `io__read_file' to read it.
Nevertheless, the interface should allow this use of io__read_file_as_string.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list