▲ | rgherdt 2 days ago | ||||||||||||||||||||||||||||||||||
That doesn't work for mutual recursion, what is quite common in Scheme programs. Besides, tail call optimization is not only useful in recursion. | |||||||||||||||||||||||||||||||||||
▲ | skrishnamurthi 2 days ago | parent [-] | ||||||||||||||||||||||||||||||||||
Tails calls are especially useful in languages with macros. You don't know what context you are in, you just generate the call that makes sense. If the call happens to be in tail-position, you get the benefit of it. Moreover, you can design cooperating macros that induce and take advantage of tail-position calls. Here's a simple example that motivates tail-calls that are not tail-recursive: https://cs.brown.edu/~sk/Publications/Papers/Published/sk-au... | |||||||||||||||||||||||||||||||||||
|