[erlang-questions] pattern matching registered name

Edmund Sumbar esumbar@REDACTED
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...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130520/f8eb953f/attachment.htm>

More information about the erlang-questions mailing list