'with' bug?
bearophile
bearophileHUGS at lycos.com
Fri Nov 2 06:13:32 PDT 2012
Adam D. Ruppe:
> D normally lets locals shadow globals silently - if you had
>
> int g;
>
> void main() {
> int g;
> }
>
> that's ok normally so it isn't specific to with. This is a good
> thing because it means adding a variable elsewhere won't
> annoyingly break your functions.
>
> You could argue that doing it on structs is a little harder to
> keep track of than regular locals, but, meh.
I try to minimize (possibly to zero) the number of global
variables/constants, but I have had some troubles caused by
silent shadowing of global names by local names in functions.
Having global variables with the same name of local variables is
sometimes a source for troubles, so I try to keep their name
distinct. But I'd like D to spot such duplications (shadowing of
a global) for me.
Bye,
bearophile
More information about the Digitalmars-d
mailing list