4 ms·
To be fair, Scheme implements tail recursion, which converts properly prepared recursion into an iterative loop. Usually converting the recursive call into a GO
by mrami 8y ago
To be fair, Scheme implements tail recursion, which converts properly prepared recursion into an iterative loop. Usually converting the recursive call into a GOTO. So if used correctly, recursion in scheme isn't a stack issue.
That said, I love my for loops, too.
- Const-me 8y ago> which converts properly prepared recursion into an iterative loop It only works if you are using recursion in place of a simple loop. Many algorithms traditionally implemented with recursion (e.g. various tree searches) need that stack somewhere. Technically it’s probably possible to “properly prepare” that, but practically both alternatives (recursion + built-in call stack, or loop + separate stack) are much easier to implement.