+ 2
What are "tail recursion" and "inline recursion" and what are their advantages?
2 Respostas
+ 3
Every time you call a function you have a bit of overhead. You need to set up a "stack frame" that contains all the function's variables and which line of code to jump back to after the function is done and things like that. And when the function is done, the stack frame is teared down.
It's not a lot of overhead but if you run the function a million times a second it's noticeable.
However! If a function calls itself, and that recursive call happens at the end of the function as the very last thing you do, you can reuse that same stack frame and save time. This is called tail call optimization.
I have never heard about inline recursion though.
+ 1
Thank you for your precise answer