3 ms·
> Tail recursion is a special way of writing recursive functions such that a compiler can optimize the recursion away and implement the algorithm as a loop inst
by lispm 7y ago
> Tail recursion is a special way of writing recursive functions such that a compiler can optimize the recursion away and implement the algorithm as a loop instead.
Typically I think more like this: a compiler will compile the tail call into a jump-like construct. Tail recursion is then just only one application of this. The compiler won't need to recognize that it is a case of recursion or a loop. Tail call optimization (TCO) is the more general form.
See Scheme from 1976:
LAMBDA, The Ultimate Imperative, by Guy Lewis Steele Jr. and Gerald Jay Sussman, MIT AI Memo 353
https://dspace.mit.edu/bitstream/handle/1721.1/5790/AIM-353.pdf https://dspace.mit.edu/bitstream/handle/1721.1/5790/AIM-353....