2 ms·
> What's the gain? You can prove that you won't have a stack overflow. You can calculate the maximum depth of the stack at compile time, not runtime.
by ktRolster 11y ago
> What's the gain?
You can prove that you won't have a stack overflow. You can calculate the maximum depth of the stack at compile time, not runtime.
- dclowd9901 11y agoCan't you also just pass a bit through the recursion that contains its depth, and halt the recursion if that number gets too high?
- ktRolster 11y agoYes, but that depends on making sure you get the programming logic correct, whereas with banning recursion outright, it can be tested automatically.
- marcosdumay 11y agoWell, you can either prove that you won't have a stack overflow at the original program, or you can not guarantee that your new code will run out of stack space. If you can calculate the size of the stack at compile time, you don't need to manually manage it.