[m-users.] spawn in Rosettacode

Robert Smart robert.kenneth.smart at gmail.com
Fri Aug 29 13:29:03 AEST 2014


At http://rosettacode.org/wiki/Concurrent_computing#Mercury, we see:

main(!IO) :-
   spawn(io.print_cc("Enjoy\n"), !IO),
   spawn(io.print_cc("Rosetta\n"), !IO),
   spawn(io.print_cc("Code\n"), !IO).

It is a bit hard to understand how this could work. My beginner's
understanding would be that the 2nd spawn couldn't happen till the first
had produced the new world that is its input parameter. Etc.

And my compilation of it (on OSX) produces the outputs in the same order as
in the program every time.

It is interesting to consider how languages which explicitly thread IO
(like Haskell and Mercury) should handle multiple interactions with the
world where the order doesn't matter, so that concurrency can be done
implicitly or explicitly.

rks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20140829/d93501c4/attachment.html>


More information about the users mailing list