<div dir="ltr"><0.33.0> was spawned when you started the interactive shell. self() is the pid of the process which is performing the function call, which in this case is the interactive shell itself.<div><br></div><div>You can test this:</div><div><br></div><div>
<p class=""><span class="">Eshell V7.2.1 (abort with ^G)</span></p><p class=""><span class="">1> c(foo),l(foo),foo:bar().</span></p><p class=""><span class="">Hello from <0.34.0></span></p><p class=""><span class=""><0.40.0></span></p><p class=""><span class="">2> self().</span></p><p class=""><span class=""><0.34.0></span></p><p class="">
</p><p class=""><span class="">3> </span></p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 21, 2016 at 2:35 PM, Dimitar Haralanov <span dir="ltr"><<a href="mailto:dharalanov@me.com" target="_blank">dharalanov@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello everyone!<br>
<br>
I am new to Erlang, but I’ve been really enjoying almost every bit of it. I stumbled upon<br>
something I am not exactly sure about. So far, my understanding is that processes are<br>
created by spawn()-ing them, however I think this is not the complete truth. I have the<br>
following contrived example:<br>
<br>
-module(foo).<br>
-export([bar/0]).<br>
<br>
bar() -><br>
io:format("Hello from ~p~n", [self()]),<br>
spawn(fun loop/0).<br>
<br>
loop() -><br>
receive<br>
Message -><br>
io:format("PID ~p received ~p~n", [self(), Message]),<br>
loop()<br>
end.<br>
<br>
and after running the code we get:<br>
<br>
1> Pid = foo:bar().<br>
Hello from <0.33.0><br>
<0.35.0><br>
2> Pid ! hello.<br>
PID <0.35.0> received hello<br>
hello<br>
3><br>
<br>
My question is - how is the process with PID <0.33.0> spawned? I’ve only read about<br>
using the erlang:spawn() function call, but I guess there are other implicit ways of starting<br>
new processes. Any further clarification would be really helpful. Thank you!<br>
<br>
Kind regards,<br>
Dimitar<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://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>