Re:ChrysaLisp
by DannyB2 on Monday January 13, 2020 @05:15PM
(#22039320)
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.
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.