Tail Call Optimization
Noun · Development
Definitions
A compiler optimization that reuses the current function's stack frame for a recursive call in tail position, converting recursion into iteration. Prevents stack overflow for deeply recursive algorithms. Guaranteed in Scheme, supported in some Scala/Kotlin modes, but notably absent from Python and most JavaScript engines.
In plain English: A compiler trick that turns recursive functions into loops behind the scenes, preventing stack overflow.
Example: "Rewrite the factorial as a tail-recursive function with an accumulator — with TCO, it runs in constant stack space."