ssledz blog

Everything should be made as simple as possible, but no simpler.

Recursive Tail Call Optimization and Trampoline

Tail call optimization (or tail call elimination) allows recursive functions to re-use the stack frame instead of creating new frames on every call.

Thanks to that an author of recursive function in tail position is not constrained by the stack size. More over such a function runs faster than the function without optimization, because calling a function doesn’t create a new stack frame which is time and resource consuming operation.

The article can be found here

Comments