[erlang-questions] Is this code tail recursive?
Max Lapshin
max.lapshin@REDACTED
Fri Sep 17 06:24:11 CEST 2010
On Fri, Sep 17, 2010 at 8:14 AM, Ryan Zezeski <rzezeski@REDACTED> wrote:
> Max, as a newb to Erlang, are you saying that without the module
> qualification and if you imported a function f/0 from another module it
> would instead call that? Actually, I just went ahead and tried that and the
> compiler gave me an error. So I ask, what are you referring to?
> -Ryan
>
As for me, I was very inattentive reading erlang tutorial and it was a
surprise for me, when following code didn't upgraded after code
upgrade:
f() ->
io:format("Hi~n"),
timer:sleep(500),
f().
It is very important to use explicit module specification:
f() ->
io:format("Hi~n"),
timer:sleep(500),
?MODULE:f().
?MODULE is a compile time constant, referring to current module and
this form of call will change code on runtime module update.
More information about the erlang-questions
mailing list