3 ms·
Sometimes it's not just a single function calling itself, but a whole bunch of functions calling into each other, which can get more confusing. This is also tr
by Rusky 4y ago
Sometimes it's not just a single function calling itself, but a whole bunch of functions calling into each other, which can get more confusing.
This is also tricky when you have indirect tail calls, because now you don't know if it's the first call to that particular function so you can't always unroll it anyway.
- skybrian 4y agoI'm thinking of something like an interpreter, where each function implements one instruction and it does tail calls to go to the next instruction, instead of having a giant switch statement in a loop. To match the implementation without tail calls, you probably don't want the previous instruction(s) on the stack, but all entry points into the interpreter should probably be on the stack.
- Rusky 4y agoYou can get this without the compiler doing any unrolling, by doing non-tail calls at the points where you enter the interpreter.