3 ms·
I'm still not a fan of tail regression, er, recursion.
by hackbinary 7y ago
I'm still not a fan of tail regression, er, recursion.
- dnautics 7y agogood news: For 99.9% of use cases, you can use the Enum module.
- ashton314 7y agoWhy not? The recursive call gets optimized away, so it's just as fast as a loop.
- aeorgnoieang 7y agoWhy not? I've always enjoyed it in languages that support it.
- pmarreck 7y agoI would perhaps agree that having to structure the code in such a way that TCO is "triggered" can be a hassle, but once you realize the pattern and learn it, it's not hard at all to refactor your code to trigger TCO. And it allows you to enjoy the semantics of an infinitely-deep stack without actually needing an infinitely-deep stack :)