On 2/14/06, <b class="gmail_sendername">Vlad Dumitrescu</b> <<a href="mailto:vlad_dumitrescu@hotmail.com">vlad_dumitrescu@hotmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>> From: Sean Hinde<br>> One thing that struck me is that they effectively have a<br>> receive construct which says:<br>><br>> receive<br>>      {Ref1, Msg1} and {Ref2, Msg2} -><br>>          do_code_only_when_both_arrived();
<br>>      Other -><br>>          handle_other_message()<br>> end<br>><br>> I know we can build this in Erlang, but not without some<br>> faffing to track what has already arrived.<br><br>Actually, they can even synchronize on messages in different mailboxes,
<br>which works fine because mailboxes aren't processes (in the Erlang sense).<br>Powerful, but IMHO creating more problems than solving (at least when<br>comparing to Erlang :-).<br><br>Except for the fact that their handlers are dynamic (which we don't have),
<br>this type of handlers could be simulated by  something like<br>        Pid = spawn(fun() -><br>                receive<br>                        {Ref1,
Msg1} -><br>                                receive
{Ref2, Msg2} -><br>                                        do_code_only_when_both_arrived()<br>                                end<br>                end),<br>        receive<br>           {Ref1, Msg1} -> Pid ! {Ref1, Msg1};
<br>           {Ref2, Msg2} -> Pid ! {Ref2, Msg2};<br>                Other -><br>                        ...<br>        end,<br>Which actually could work even for Msg1 and Msg2 coming from different<br>processes (the problem being how to let them know the value of Pid).
<br><br><br>Also, I wonder how easy it is to keep track of all handlers that are<br>installed on a single port at any moment in time. How am I supposed to<br>choose the proper match predicate if I don't know what other predicates are
<br>active on that port? If I don't get a message that I expect, is it because<br>it didn't arrive at all, or because some other handler ate it up? *brrr* a<br>nightmare to debug...<br><br>Comparing to a receive statement, where all cases are explicit, I think my
<br>bias is clear ;-)<br><br>Alternatively, I might have misunderstood everything completely. ;-)<br><br>Regards,<br>Vlad<br><br><br></blockquote></div><br>
IMHO, your bias is well founded. Reading through the Polyphonic C#
whitepaper (nice spin :) ), it seems to me that the approach would
mitigate some of the monitor/mutex/semaphore pain, but ultimately not
by much. It might make that kind of concurrent programming easier in
some instances, but generally it seems to me to be too little, possibly
too late.<br>
And not even a mention of Erlang in the whole document. Pfft.<br>
<br>