[erlang-questions] escript and tail recursion

Paul Guyot <>
Fri Apr 3 09:50:47 CEST 2009


Hello,

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?

Paul




More information about the erlang-questions mailing list