3 ms·
Tail calls aren't just for loops. Tail calls can be across functions. A calls B calls C calls A calls B ... repeat until ... one of the functions solves the p
by DannyB2 7y ago
Tail calls aren't just for loops. Tail calls can be across functions.
A calls B calls C calls A calls B ... repeat until ... one of the functions solves the problem and does a return. Then the stack is unwound. But with TCO all of the tail calls simply re-use the current stack frame and JUMP to the next function.