3 ms·
A comment on the site itself noted that tail recursion does not imply parallelization -- in fact, I would make a stronger statement that it forces serial exec
by Roboprog 16y ago
A comment on the site itself noted that tail recursion does not imply parallelization -- in fact, I would make a stronger statement that it forces serial execution, at least as far as funneling results of one "iteration" into the next.
The benefit, as "everybody" here of course already knows, is to reduce memory (call stack) usage.
Knowing how to implement tail recursion allows you to write in an "assign only once" type of language, without blowing up the stack. And using such "invariant symbols" in a routine allows the compiler/interpreter to seek parallelization at other points in the function on your behalf. OK, so I just contradicted myself, but the point is there is an rather indirect connection between tail recursion and parallelization.