[erlang-questions] pattern matching registered name
Mon May 20 20:47:05 CEST 2013
On Mon, May 20, 2013 at 11:47 AM, James Aimonetti <james@REDACTED> wrote:
> rpc/2 expects the first arg into the function to be the first element
> in the response tuple.
> The loop/0 uses self(), which always returns a pid(), not the
> registered name.
> So you call rpc with an atom, and receive a tuple with a pid(). Those
> don't match.
> Your call to rpc/2 hangs because the selective receive in rpc/2 never
> matches (and you have no timeout clause).
What's confusing is that the atom apparently resolves into a pid() in the
send expression of kvsx:rpc/2 (adding io:format("reg name = ~p~n",
[whereis(abc)]) to the function returns the pid()), but not in the pattern
tuple of the receive expression.
Anyway, thanks for the replies James and Yogish.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions