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

Walter Bright newshound2 at digitalmars.com
Sun Nov 24 10:23:53 PST 2013


On 11/24/2013 9:45 AM, Andrei Alexandrescu wrote:
> Sorry, I misread the example - thought it's a function local variable. I'm not
> sure whether shadowing globals or members would be a good idea. gcc has a -W
> flag for that, and someone tried to turn it on at Facebook but with debatable
> results. We ended up not using that warning.

Shadowing globals is definitely a bad idea. Shadowing members, it's debatable. 
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. I find code like this to be 
unduly wretched:

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


More information about the Digitalmars-d mailing list