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

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Oct 9 14:04:08 AEDT 2000


On 09-Oct-2000, Michael Day <mcda at students.cs.mu.oz.au> wrote:
> 
> > 	:- mode with_stream(pred(out, di, uo) is det, out, di, uo) is det.
> > 	with_stream(Pred, Result, S0, S) -->
> > 		stream__init(S0, Stream0),
> > 		{ Pred(Result, Stream0, Stream) },
> > 		stream__destroy(Stream, S).
> 
> Hmm wouldn't it be necessary to pass the io__state through to the
> predicate as well as the stream, so that it can open new streams itself
> and perform other io? Otherwise doesn't it restrict you to only opening
> one stream at a time?

Yes, good point.  That should be

 	:- pred with_stream(pred(Res, state(S), state(S), io__state, io__state),
		Res, S, S, io__state, io__state) is det.
 	:- mode with_stream(pred(out, di, uo, di, uo) is det, out, di, uo,
		di, uo) is det.
 	with_stream(Pred, Result, S0, S) -->
 		stream__init(S0, Stream0),
 		Pred(Result, Stream0, Stream),
 		stream__destroy(Stream, S).

-- 
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