The 'Tail Position' Rule: TCO's Strict Condition

For Tail Call Optimization to occur, the recursive call must be the absolute last operation within the function. Any subsequent computation, like an addition or multiplication with the call's result, prevents it from being a true 'tail call' and thus blocks the optimization.

Sources

Open the full topic