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

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Oct 3 11:37:37 AEDT 2000


On 02-Oct-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> >From Fergus Henderson on 02/10/2000 15:12:14
> > These approaches don't have to be mutually exclusive, of course.
> > There may be a case for providing all three:
> > 	- one to use when you care about the order of side effects
> 
> Use explicit handles (e.g. io__streams with io__states)

Right, but this approach should still be generalised (using
type classes) to allow user-defined stream types.

> > 	- one to use when you know that the order of side effects
> > 	  won't influence the result
> 
> :- pred io__unsafe_fork_io(io__state::uo, io__state::di, io__state::uo) is
> det.
> 
> mayhap?

I think that has the same problems as stream__init/stream__destroy.

I was thinking of a solution using streams and file locking for this case --
like the one that Peter Ross has been proposing, except using `with_stream'
rather than stream__init/stream__destroy.
That way it is at least run-time checked, rather than unchecked.
The overhead of the run-time checking is probably not too bad since
it only requires extra work for each stream open/close, not when
writing individual characters.

> > 	- one to use when you don't care about the order of side
> > 	  effects, even though they may influence the result
> 
> :- pred io__join(io__state::di, io__state::di, io__state::uo) is cc_multi.
> 
> Okay, this needs a bit of work...

Well, `spawn' in extras/concurrency/spawn.m provides one way of doing this.
And if you just want

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