[mercury-users] Request for comments on this code

Peter Schachte schachte at csse.unimelb.edu.au
Tue Jul 11 18:03:31 AEST 2006


On Tue, Jul 11, 2006 at 01:32:03PM +1000, Ian MacLarty wrote:
> On Tue, Jul 11, 2006 at 12:03:55PM +1000, Peter Schachte wrote:
> > On Tue, Jul 11, 2006 at 11:15:35AM +1000, Ian MacLarty wrote:
> > 
> > > For every IO primitive executed in the program the first IO state
> > > argument is the state of the universe at the time that IO primitive is
> > > executed, while the second IO state argument is the state of the
> > > universe at the time the *next* IO primitive is executed.  The first
> > > argument of main/2 is thus the state of the universe at the time the
> > > first IO primitive in the program is executed and the second argument is
> > > the state of the universe when the program terminates (if main does
> > > nothing then both arguments are the state of the universe at the time
> > > the program terminates).

If you take that view, then you really don't need to thread the IO
state anywhere, since the IO state after a call to an IO primitive
holds the state of the world at the time of the next IO primitive,
including anything I might read from or write to IO streams.

We need to thread the IO state through the code to keep the actions
that effect the "state of the universe" in the right order.  So you
don't want to consider too many things to be part of the "state of the
universe," because you'll have to thread the IO state through
everything that effects any of those things, at least if you care
about the order they happen in.  You can't get around that by
declaring that the state of the world psychically determines
everything that's going to happen before the next IO action, including
things inside Mercury, because that doesn't distinguish goals that
cannot be reordered from goals that can.

-- 
Peter Schachte              The trouble with Communism is the Communists,
schachte at cs.mu.OZ.AU        just as the trouble with Christianity is the
www.cs.mu.oz.au/~schachte/  Christians.
Phone: +61 3 8344 1338          -- H.L. Mencken 
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at csse.unimelb.edu.au
administrative address: owner-mercury-users at csse.unimelb.edu.au
unsubscribe: Address: mercury-users-request at csse.unimelb.edu.au Message: unsubscribe
subscribe:   Address: mercury-users-request at csse.unimelb.edu.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list