getResults(N) -><br>
receive<br>
{Test, ET, N, Bytes, Pid} -><br><br>N is already bound and the receive clause <br>wont match unless its equal <br><br><div class="gmail_quote">2009/3/4 Allen McPherson <span dir="ltr"><<a href="mailto:mcpherson@lanl.gov">mcpherson@lanl.gov</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;">I have the following receive loop:<br>
<br>
getResults(0) -><br>
'getResults ok';<br>
getResults(N) -><br>
receive<br>
{Test, ET, N, Bytes, Pid} -><br>
io:format("~p: ET: ~p~n", [Test, ET]),<br>
getResults(N-1);<br>
'unknown test' -><br>
io:format("unknown test~n"),<br>
getResults(N-1);<br>
Any -><br>
io:format("~p~n", [Any]),<br>
getResults(N-1)<br>
end.<br>
<br>
<br>
When it is sent the following message:<br>
<br>
MasterPid ! {allpairs, timer(wall_clock), N, Bytes, self()},<br>
<br>
..the Any clause (which I put in for debugging purposes because nothing<br>
was matching and the receive was blocking) matches and prints the<br>
following:<br>
<br>
{allpairs,2346,100,1048576,<6083.48.0>}<br>
{allpairs,2109,100,1048576,<6084.38.0>}<br>
{allpairs,2152,100,1048576,<6041.48.0>}<br>
{allpairs,2159,100,1048576,<6082.48.0>}<br>
<br>
I would have thought the first clause should have matched?<br>
I tested in the shell:<br>
<br>
(foo@pn1169360)1> {Test, ET, N, Bytes, Pid} = {allpairs,<br>
2346,100,1048576,<6083.48.0>}.<br>
1: syntax error before: '<'<br>
<br>
The shell does not like the Pid syntax and I've Googled around to see<br>
why this<br>
is a problem even when using pid_to_list and list_to_pid.<br>
This works though:<br>
<br>
(foo@pn1169360)1> {Test, ET, N, Bytes, Pid} = {allpairs,<br>
2346,100,1048576,self()}.<br>
{allpairs,2346,100,1048576,<0.37.0>}<br>
<br>
And, removing Pid in shell works too:<br>
<br>
(foo@pn1169360)1> {Test, ET, N, Bytes} = {allpairs,2346,100,1048576}.<br>
{allpairs,2346,100,1048576}<br>
<br>
The same tactic (removing Pid) in the code still matches the Any clause.<br>
<br>
Perhaps I'm not understanding something fundamental here? I suspect<br>
this is<br>
a dumb mistake on my part but I can't see it.<br>
<font color="#888888"><br>
--<br>
Al<br>
<br>
<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>
</font></blockquote></div><br>