[erlang-questions] escript and tail recursion
Hakan Mattsson
hakan@REDACTED
Tue May 5 09:58:09 CEST 2009
On Fri, 3 Apr 2009, Paul Guyot wrote:
> I've just noticed that tail recursive functions in interpreted escript
> scripts are not tail recursive at all.
>
> Here is a sample script :
>
> > tail_r() ->
> > io:format("~p~n", [element(2, process_info(self(), stack_size))]),
> > tail_r().
> >
> > main([]) ->
> > tail_r().
>
> The function is tail-recursive if -mode(compile) is used. Is it a
> known limitation of escript? (this is R12B). If so, shouldn't it be
> mentioned in the escript documentation?
Interpreted escripts will be tail recursive in next release.
Thanks for pointing this out.
/Håkan
---
Håkan Mattsson (uabhams)
Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list