<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<br class=""><br class="">By accident, I found erlang:list_to_pid/1 does not produce the same "thing" when putting remote pid string as the argument.<br class=""><br class="">And, I found this mailing list post: <a href="http://erlang.org/pipermail/erlang-questions/2009-February/042100.html" class="">http://erlang.org/pipermail/erlang-questions/2009-February/042100.html</a><div class=""><br class=""><div class="">Quite interesting, but I still can't figure out why after reading the whole post.<br class=""><br class="">I checked the source code, a function called list_to_pid_1() in erts/emulator/beam/bif.c handles this. Honestly speaking, I can't fully understand it. So I did some guess work.<br class=""><br class="">I wrote a simple module:<div class=""><br class="">%%<br class="">%% A dist demo.<br class="">%%<br class="">-module(a_dist_demo).<br class=""><br class="">-export([start/1, loop/0]).<br class=""><br class="">start(Node) -><br class=""> spawn(Node, fun() -> loop() end).<br class=""><br class="">loop() -><br class=""> receive<br class=""> {From, {echo, Any}} -><br class=""> From ! Any,<br class=""> loop()<br class=""> end.<br class=""><br class=""><div class="">And two nodes get started:</div><div class=""><br class=""></div></div><div class=""><div class="">MacBookPro:code by$ erl -name yao1</div><div class="">Erlang/OTP 22 [erts-10.5.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]</div><div class="">Eshell V10.5.3 (abort with ^G)</div><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)1> Pid = a_dist_demo:start('<a href="mailto:yao2@MacBookPro.local" class="">yao2@MacBookPro.local</a>').</div><div class=""><9172.91.0></div><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)2> Bin = erlang:term_to_binary(Pid).</div><div class=""><<131,103,100,0,21,121,97,111,50,64,77,97,99,66,111,111,</div><div class=""> 107,80,114,111,46,108,111,99,97,108,0,0,0,...>></div><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)3> io:format("~p~n", [Bin]).</div><div class=""><<131,103,100,0,21,121,97,111,50,64,77,97,99,66,111,111,107,80,114,111,46,108,</div><div class=""> 111,99,97,108,0,0,0,91,0,0,0,0,2>></div><div class="">ok</div><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)4> Pid ! {self(), {echo, abcd}}.</div><div class="">{<0.87.0>,{echo,abcd}}</div><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)5> receive X -> X end.</div><div class="">abcd</div></div><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)6></div><div class=""><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)8> Pid1 = erlang:list_to_pid("<9172.91.0>").</div><div class=""><9172.91.0></div></div><div class=""><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)9> Pid = Pid1.</div><div class="">** exception error: no match of right hand side value <9172.91.0></div></div><div class=""><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)11> Bin1 = erlang:term_to_binary(Pid1).</div><div class=""><<131,103,100,0,21,121,97,111,50,64,77,97,99,66,111,111,</div><div class=""> 107,80,114,111,46,108,111,99,97,108,0,0,0,бн>></div></div><div class=""><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)12> Bin = Bin1.</div><div class="">** exception error: no match of right hand side value </div><div class=""> <<131,103,100,0,21,121,97,111,50,64,77,97,99,66,111,111,</div><div class=""> 107,80,114,111,46,108,111,99,97,108,0,0,0,...>></div><div class="">(<a href="mailto:yao1@MacBookPro.local" class="">yao1@MacBookPro.local</a>)13></div></div><div class=""><br class=""></div><div class=""><div class="">MacBookPro:code by$ erl -name yao2</div><div class="">Erlang/OTP 22 [erts-10.5.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]</div><div class="">Eshell V10.5.3 (abort with ^G)</div><div class="">(<a href="mailto:yao2@MacBookPro.local" class="">yao2@MacBookPro.local</a>)1> Bin = <<131,103,100,0,21,121,97,111,50,64,77,97,99,66,111,111,107,80,114,111,46,108,111,99,97,108,0,0,0,91,0,0,0,0,2>>.</div><div class=""><<131,103,100,0,21,121,97,111,50,64,77,97,99,66,111,111,</div><div class=""> 107,80,114,111,46,108,111,99,97,108,0,0,0,...>></div><div class="">(<a href="mailto:yao2@MacBookPro.local" class="">yao2@MacBookPro.local</a>)2> Pid = erlang:binary_to_term(Bin).</div><div class=""><0.91.0></div><div class="">(<a href="mailto:yao2@MacBookPro.local" class="">yao2@MacBookPro.local</a>)3> Pid ! {self(), {echo, 1234}}.</div><div class="">{<0.87.0>,{echo,1234}}</div><div class="">(<a href="mailto:yao2@MacBookPro.local" class="">yao2@MacBookPro.local</a>)4> receive X -> X end.</div><div class="">1234</div><div class="">(<a href="mailto:yao2@MacBookPro.local" class="">yao2@MacBookPro.local</a>)5></div></div><div class=""><br class=""></div><div class="">The result is: the same binary produces two different shapes of pid ( <9172.91.0> and <0.91.0> ) in two nodes. Apparently, they refer to the same process.</div><div class=""><br class=""></div><div class="">I guess the remote pid need some unique information came from the remote node, and erlang:list_to_pid/1 just do not have those information.</div><div class=""><br class=""></div><div class="">I hope some internal thoughts can be revealed for this.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Yao</div><div class=""><br class=""></div></div></div></body></html>