Message {test, test1, test2} is first in the message. foo is second.<br>Similarly as in original receive I take the newest message and check if only with this message I can satisfy any of the joins.<br>If that is not possible, then I go the next message and check if any of the joins can be satisfied using the new message (and all previous ones).<br>
Since {test, test1, test2} already satisfies one of the joins, then I fire it immediately and do not look at what else is in the message<br>after {test, test1, test2} (though I might obviously look at it in the future, if I have any receive constructs afterwards).<br>
<br>I hope that helps. <br><br><br><br><div class="gmail_quote">2009/3/9 Hynek Vychodil <span dir="ltr"><<a href="mailto:vychodil.hynek@gmail.com">vychodil.hynek@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This test case is not clear for me:<div class="im"><br><br>self() ! {test, test1, test2},<br>self() ! foo,<br> ok = receive<br> _X and foo -><br> error;<br> X -><br> {test, _, _} = X,<br>
ok<br>
end,<br><br></div>Can you describe more verbosely why first pattern should not match.<br><br><div class="gmail_quote">2009/3/9 Hubert Plociniczak <span dir="ltr"><<a href="mailto:hubert.plociniczak@googlemail.com" target="_blank">hubert.plociniczak@googlemail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5"><br><br><div class="gmail_quote">2009/3/8 Vlad Dumitrescu <span dir="ltr"><<a href="mailto:vladdu55@gmail.com" target="_blank">vladdu55@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<div><br>
<br><div>> receive<br>
> {foo, One} and {bar, Two} when (One > Two) -><br>
> expr.....;<br>
> ....<br>
> end<br>
<br>
</div>Thiss looks interesting, but could you please describe the semantics<br>
of the above example? Does it match for the two messages in sequence,<br>
does one of them have to be the first in queue, is order important?<br>
</div></blockquote><div><br>Let's assume that in the mailbox we have messages(from oldest to newest):<br>[ {foo, 12}, {bar, 2} ] <br>or<br>[ {bar, 2}, {foo, 12} ]<br>Then both will match because I check all the possible permutations. The order is important when we have<br>
more Joins and it works in a similar way as standard selective receive, i.e. the first valid permutation will match.<br> <br></div></div>Here is an extract from my test cases to give you an idea of what I want to achieve (should be self-explanatory):<br>
<br> self() ! foo,<br> self() ! foo, <br> self() ! foo,<br> self() ! foo,<br> ok = receive<br> foo and foo and foo and foo -><br> ok<br> end,<br><br> clear_mailbox(), %% purge all messages<br>
self() ! {one, 1},<br> self() ! {two, 3},<br> Z = 4,<br> A = 1,<br> ok = receive<br> {two, 3} and {one, Z} -><br> error;<br> {two, 3} and {one, A} -><br> ok<br> end,<br>
self() ! {test, test1, test2},<br> self() ! foo,<br> ok = receive<br> _X and foo -><br> error;<br> X -><br> {test, _, _} = X,<br> ok<br> end,<br> self() ! {test1, 10},<br>
self() ! {test2, 15},<br> self() ! {test3, 10},<br> ok = receive<br> {C, X1} and {B, X1} -><br> try<br> C = test1,<br> B = test3,<br> ok<br> catch<br>
error:{badmatch, _} -><br> C = test3,<br> B = test1,<br> ok<br> end <br> end.<br><br>I am also working on Operational Semantics for this extended version of Erlang with Joins, but it is still work in progress.<br>
<br>Zvi, <br><div><br>>nice work. Does it work only inside receive or for any pattern match?<br>
>If it's supporting generic pattern matching, I would suggest, rewriting<br>>mochiweb HTML parser, using your join patterns.<br><br></div>This is only designed for matching on the messages in the mailbox.<br><font color="#888888"><br>
hubert<br>
<br><br><br>
</font><br></div></div><div class="im">_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br></div></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>
--Hynek (Pichi) Vychodil<br>
<br>Analyze your data in minutes. Share your insights instantly. Thrill your boss. Be a data hero!<br>Try Good Data now for free: <a href="http://www.gooddata.com" target="_blank">www.gooddata.com</a><br>
</font></blockquote></div><br>