3 ms·
> And your rule for safer variables with minimal scoping requires the programmer to understand the lifetime and usage of different variables, and appreciate why
by jcelerier 5y ago
> And your rule for safer variables with minimal scoping requires the programmer to understand the lifetime and usage of different variables, and appreciate why it's bad to re-use things in a confusing way across a function.
No, there is nothing to understand: the rule to minimize a variable's scope is mechanical.
> But, if they understand that then surely they can already write good code: with or without minimal scoping? What's the difference?
No. It's impossible to assume that even the very best programmer writes good code consistently, thus every possibility for failure must be automatized or mechanized.
- veltas 5y ago> No, there is nothing to understand: the rule to minimize a variable's scope is mechanical. I tried to explain my answer to this in my third paragraph. > It's impossible to assume that even the very best programmer writes good code consistently, thus every possibility for failure must be automatized or mechanized. This is a strawman, if I thought the feature was useful to prevent this I would give it more consideration. I have already attempted to explain why I don't think conservative scoping aids bad/confusing variable re-use.