2 ms·
The reason you know that a function won't modify locals is not because of limitations on what a function can do, but because of what has not been done locally:
by kazinator 9y ago
The reason you know that a function won't modify locals is not because of limitations on what a function can do, but because of what has not been done locally: your lexical scope has not been captured in a lexical closure; or else, that closure has not escaped; or else, if it has escaped, its body doesn't contain any code which mutates variables.
The space of things that a function won't do is tiny compared to the space of what it may. You've taken a vast universe of possible behavior and eliminated from it a few possibilities like mutation of a local variable in the caller; that still leaves a vast space. Generally, to maintain code, at some point you have to grapple with understanding what it does more than with what it doesn't do.