[erlang-questions] tail recursion
Jason Dusek
jsnx@REDACTED
Thu May 31 02:26:01 CEST 2007
Hi All,
I have a server like this:
server({X, Y}) ->
receive
{update, NewState} ->
server(NewState);
{x, Client} ->
Client ! X,
server({X, Y});
{y, Client} ->
Client ! Y,
server({X, Y});
end
.
Its tail recursive but, unfortunately, a little redundant -- I'd like
to rewrite it like this:
server({X, Y}) ->
receive
{update, NewState} ->
server(NewState);
{x, Client} ->
Client ! X;
{y, Client} ->
Client ! Y;
end,
server({X, Y})
.
But I worry that the compiler and interpreter will fail to recognize
my server as tail recursive. Will my rewrite blow the stack?
--
_jsn
More information about the erlang-questions
mailing list