3 ms·
of course you can, and trivially so; just return the next function to call from (as a pointer or some other identifier as a result of each state function.
by gpderetta 8y ago
of course you can, and trivially so; just return the next function to call from (as a pointer or some other identifier as a result of each state function.
- noelwelsh 8y agoThat's called a trampoline, and is one of the ways to simulate tail recursion. It requires a global modification to the code: you have to rewrite all your code that you want to be stack-safe to be trampolined. It wouldn't call that trivial, but then Node developers are happy to rewrite their code into CPS so what do I know.
- gpderetta 8y agoat the end of the day it is always continuations all the way down.