3 ms·
No, seriously, it's easy: Is there exactly one assignment location that's not in a loop or a conditional? yes => constant ; no => non-constant This is neithe
by StefanKarpinski 12y ago
No, seriously, it's easy:
Is there exactly one assignment location that's not in a loop or a conditional?
yes => constant ; no => non-constant
This is neither hard nor unintuitive.
- frowaway001 12y agoSo you are recommending to create a special case just for declarations in local scope? So "var" in global places means "variable", but "var" in local places means "variable or value"?
- StefanKarpinski 12y agoI'm not recommending anything. I'm wondering what the point of declaring something that's obvious from a simple syntactic analysis is. The author of this post makes a big deal of it and I don't see why it's useful. If the motivation is that constness is the right default in global scope and you want to make local and global scope more similar (even though they are still radically different), that's cool, but then don't make it out like local variables defaulting to const is the best thing ever invented.