Comment by jiggawatts

3 months ago

A useful purpose for such a thing is in certain embedded, hard-real-time, or mission-critical scenarios.

Many such programming environments need strict control over stack sizes to avoid any possibility of stack overflow.

I had a similar notion a few years back, thinking about a somewhat wider range of "scoped guarantees". The compiler would compute things such as the maximum stack usage of a function, and this would "roll up" to call sites automatically. This could also be used to enforce non-usage of certain dangerous features such as locks, global flags, or whatever.