[m-dev.] for review - new stuff for the extras directory.

Ralph Becket rbeck at microsoft.com
Tue Feb 29 21:11:11 AEDT 2000


> From: Thomas Conway [mailto:conway at cs.mu.OZ.AU]
>
> > :- pred loop_forever(io__state, io__state).
> > :- mode loop_forever(di, uo) is det.
> > 
> > loop_forever --> yield, loop_forever.
> 
> Hmmm, it looks like my reply turned into a more detailed explanation
> of my semantics of coroutining than I set out for, but never mind...
> I was just going to point out that your loop_forever (not having seen
> how you use it yet), is unlikely to do anything useful.

Indeed, it doesn't do anything useful.  I was making a (daft)
assumption after looking at your code when I should have asked a
question :)

In your code, you wrote:

main -->
	new(Lock), signal(Lock),
	new(forks(yes, yes, yes, yes, yes), ForkGlob),
	spawn(philosopher(plato, Lock, ForkGlob)),
	spawn(philosopher(aristotle, Lock, ForkGlob)),
	spawn(philosopher(descartes, Lock, ForkGlob)),
	spawn(philosopher(russell, Lock, ForkGlob)),
	      philosopher(sartre, Lock, ForkGlob).

Because of the last call not being a spawn, I had this nagging doubt as 
to whether all child processes would be killed once the parent terminated,
but this is of course nonsense as your explanation of the semantics of
spawn (which is also quite understandable from the original comment, IMO) 
makes clear.

So just elide all reference to loop_forever//0 in my code.

Cheers,

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