DMD can implicitly convert class pointer to the bool. Is it bug or terrible feature?

bearophile bearophileHUGS at lycos.com
Sun Nov 24 11:17:36 PST 2013


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


More information about the Digitalmars-d mailing list