<br><div class="gmail_quote">On Fri, Sep 16, 2011 at 9:38 AM, Jovi Zhang <span dir="ltr"><<a href="mailto:bookjovi@gmail.com">bookjovi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
I am a newbie of Erlang, here I have a question for receive<br>
message in Erlang loop.<br>
Like below Erlang code, when process receive one message, it will<br>
invoke loop again,<br>
then it can service like a server, receive message forever.<br>
BUT is possible that process will stack overflow after receive too<br>
many message? the process invoke loop again and again.<br>
<br>
I saw there have many code write like this in <<Programming Erlang>> book.<br>
<br>
loop() -><br>
receive<br>
hello -><br>
io:format("hello\n"),<br>
loop();<br>
Other -><br>
io:format("I don't know what is this message, ~p is ~n" ,[Other]),<br>
loop()<br>
end.<br>
<br></blockquote><div><br>No stack overflow, due to tail call optimisation. See also <a href="http://www.erlang.org/doc/reference_manual/functions.html#id74170">http://www.erlang.org/doc/reference_manual/functions.html#id74170</a><br>
<br>Robby<br> <br></div></div><br>