[m-dev.] for review: stream I/O

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Oct 3 00:25:58 AEDT 2000


On 02-Oct-2000, Peter Ross <petdr at miscrit.be> wrote:
> On Mon, Oct 02, 2000 at 07:08:20PM +1100, Fergus Henderson wrote:
> > Hmm... you haven't provided any way to reset the error indicator,
> > have you?  It might be a good idea to provide something like ANSI C's
> > clearerr() function.  Otherwise there is no way to recover once
> > an error has occurred on a stream, except by closing the stream
> > and re-opening it.
>
> Document that the is_error predicate is responsible for clearing the
> error status of a stream once it has reported an error?

That sounds like a reasonable solution.
But if so, I suggest you rename the procedure as `get_error'.

> > > +	% Define read/write one character whose signatures obey the
> > > +	% constraints of the stream type classes.
> > > +
> > > +:- pred pure_read_char(stream__result(char),
> > > +		impure(S), impure(S)) <= impure__input(S).
> > > +:- mode pure_read_char(out, di, uo) is det.
> > > +
> > > +:- pred pure_write_char(char, impure(S), impure(S)) <= impure__output(S).
> > > +:- mode pure_write_char(in, di, uo) is det.
> > 
> > The comment here doesn't make grammatical sense, and doesn't really
> > explain what these procedures do.
> 
> Read one character of input.  This read character implementation can be
> used in instance declarations for the stream__input type class.
> 
> Write one character of input.  This write character implementation can be
> used in instance declarations for the stream__output type class.

That looks much better.

(But there's a cut-and-paste error: s/of input/of output/.)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list