4 ms·
> Recursion is a bad idea Raw recursion or recursion using recursive schemes?
by turingspiritfly 8y ago
> Recursion is a bad idea
Raw recursion or recursion using recursive schemes?
- AnimalMuppet 8y agoAny recursion. The problem is that, without tail call optimization, you create one stack frame per recursion. In Nokinside's world, you have to prove that you will never exceed the stack size. To prove that, you have to prove an upper bound on the number of recursion calls, and multiply by the size of a call's stack frame. Proving it for iteration is much easier, partly because (under the MISRA C rules or similar) iterations must have fixed bounds, but mostly because you don't create a stack frame for each iteration. My turn: What's a recursive scheme?