Hacker News new | ask | show | jobs
by JonChesterfield 1064 days 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.

1 comments

Inferring 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.