[mercury-users] Request for comments on this code
Peter Schachte
schachte at csse.unimelb.edu.au
Tue Jul 11 17:43:15 AEST 2006
On Tue, Jul 11, 2006 at 03:46:35PM +1000, Ralph Becket wrote:
> That is, when I write
>
> io.print(..., !IO),
>
> what really happens is
>
> universe_gets_a_turn(!IO),
> io.print(..., !IO),
> universe_gets_a_turn(!IO),
>
> What the universe does, however, is cc_multi (i.e., for any IO state
> there are many possible successor IO states, but we only get one of
> them and we can't backtrack.)
Hmmmm, the cc_multi-ness vs. det-ness of the rest of the universe is
an interesting open philosophical question, but I don't think we need
to resolve it. We'd better not need to because I can't tell the
difference between "the universe could do any number of things, but it
only does one and you can't ask for a retry" and "the universe can
only ever do one thing." Free will vs. determinism.
> Under that interpretation, IO operations should be cc_multi.
I think it's better to think of it as coroutining between your program
and the rest of the universe. So when you execute
io.low_level_action(..., IO0, IO1)
where low_level_action is outside Mercury, what you're really doing is
sending a message to the universe on channel IO0 asking it to perform
the low level action, whereupon it supplies you with a fresh channel
IO1. This seems like a better model of what's happening, since
between the time I get an IO state and when I use it, the state of the
universe changes. So it doesn't make sense to think of the IO state
as *holding* the universe, but it's still fine to think of it as a
channel to the universe.
You know, no matter how deep I dig, it still seems to be worms all the
way down. I don't have a good answer, but I'm still convinced that
it's wrong to include as part of the IO state things that Mercury can
affect without threading an IO state.
--
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