According to http://www.erlang.org/doc/efficiency_guide/myths.html
In R12B and later releases, there is an optimization that will in many cases reduces the number of words used on the stack in body-recursive calls, so that a body-recursive list function and tail-recursive function that calls lists:reverse/1<../man/lists.html#reverse-1> at the end will use exactly the same amount of memory. lists:map/2, lists:filter/2, list comprehensions, and many other recursive functions now use the same amount of space as their tail-recursive equivalents.
Can someone tell me, what exactly is the optimization that was done in R12B? It must be something in the runtime system that recognizes these conditions and does something smart; I'd love to be able to be equally smart.
Kresten Krab Thorup, Trifork
________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-questio...@erlang.org
No, it's a compiler optimization - stack trimming. List comprehensions and
other body recursive calls used to eat even more stack space before R12.
(The only support that was added to the run-time system was the trim/2
instruction to do the actual stack trimming.)
--
Björn Gustavsson, Erlang/OTP, Ericsson AB