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

bearophile bearophileHUGS at lycos.com
Sun Nov 24 07:35:39 PST 2013


Maxim Fomin:

> This is identifiers shadowing issue. In best case you could not 
> define boolean f, so the problem would not arise in a first 
> place.

See also the discussion here:
http://d.puremagic.com/issues/show_bug.cgi?id=9521

Is it right for with to not give an error here?


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


Silent shadowing of global (module-level in both Python and D) 
names has caused me many problems along the years.

Bye,
bearophile


More information about the Digitalmars-d mailing list