This test case is not clear for me:<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>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">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;"><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 class="im"><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 class="im"><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>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">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></blockquote></div><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">www.gooddata.com</a><br>