Recursion without optimizations requires a possibly unbounded stack. Tail call optimization allows optimizing certain recursive functions in a way that no nested stack frames are needed.
So from a purely functional point of view, tail recursion and iteration are essentially a bijection.
Comments
Recursion without optimizations requires a possibly unbounded stack. Tail call optimization allows optimizing certain recursive functions in a way that no nested stack frames are needed.
So from a purely functional point of view, tail recursion and iteration are essentially a bijection.