Re:Finite State Machines
by elviejo on Monday February 22, 2021 @09:53AM
(#26225171)
What is TCO?
what are languages that implement TCO?
[ Parent
| on HN ]
Tail Call Optimization, better called Tail Call Elimination. Haskell, OCaml, Erlang/Elixir, Scala with @tailrec, Scheme, Lua(!), most other functional languages.
Basically, if there's a call to a function B at the very end of function A, there's no need to create a new stack frame for the call to B - you can reuse the frame created for call to A. It both saves memory and improves performance. A special case is when A and B are both the same function, in which case we say A is tail-recursive.