Walter Bright:

Shadowing globals is definitely a bad idea. Shadowing members, it's debatable.

So are you saying D here should give an error for the shadowing of the module-level x?


struct Foo { int x; }
int x;
void main() {
    Foo f;
    with (f) {
        x++;
    }
}




In any case, I don't think it is some sort of terrible bug generator. In fact, I'll often write:

struct S {
    int m;
    this(int m) { this.m = m; }
}

because I like to make it clear I am initializing m.

From my experience that's quite bug-prone:
http://d.puremagic.com/issues/show_bug.cgi?id=3878

Bye,
bearophile

Reply via email to