On 6/9/2015 1:06 PM, Shachar Shemesh wrote:
In practice, when your code gets big enough in a certain field, similar names
are pretty much unavoidable. Admittedly, this is mostly around variable names. I
lost count over the number of variables called "diskIdx" I have. While not
exactly duplicate per-se, there is also a (member) function by that name. Try to
find where "diskIdx" is defined, and you /will/ get swamped.

First off, D does not allow "shadowing" local variable declarations. Secondly, if you've got a lot of global variables, you've got a program design problem anyway. And lastly, naming everything "diskIdx" is a problem of your own creation.

You could design a language that does not allow any duplicate names anywhere, and no scoping rules would be required. But there's a reason no such language has caught on - it does not scale and is unusable.

I take that back, early BASIC implementations did have such. You could only have single letter names followed by a single digit, and all names were global and hence must be unique. What a relief to leave that behind.

Reply via email to