3 ms·
Maximum stack usage can be calculated in the presence of recursion. Tail calls can be handled as branches instead of nested call frames, but also non-tail calls
by JonChesterfield 3y ago
Maximum stack usage can be calculated in the presence of recursion. Tail calls can be handled as branches instead of nested call frames, but also non-tail calls are tolerable if you have (or can infer) some measure to determine maximum call stack depth.
It's a pain, and the type system rejecting any recursion is certainly simpler, but that's not a strict requirement.
- _0w8t 3y agoInferring the number of loop integrations or recursion levels is in practice impossible when the number depends on the user input. For a system language I would like to see that when the compiler cannot infer the bound on the stack size or when that static bound exceeds some static limit, a function call is treated as fallible.