Tail-call optimization
Factor handbook > The language > Stack machine model


If the last action performed is the execution of a word, the current quotation is not saved on the call stack; this is known as tail-call optimization and the Factor implementation guarantees that it will be performed.

Tail-call optimization allows iterative algorithms to be implemented in an efficient manner using recursion, without the need for any kind of primitive looping construct in the language. However, in practice, most iteration is performed via combinators such as while, each, map, assoc-each, and so on. The definitions of these combinators do bottom-out in recursive words, however.