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

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Nov 24 09:45:26 PST 2013


On 11/24/13 9:39 AM, bearophile wrote:
> Are you saying this code gives or should give errors?
>
>
> class Foo {}
> class Bar {
>       Foo f;
>       void bar() {
>           bool f = true;
>           if (f) {}
>       }
> }
> void main() {}

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.

Andrei



More information about the Digitalmars-d mailing list