DMD can implicitly convert class pointer to the bool. Is it bug or terrible feature?
Maxim Fomin
maxim at maxim-fomin.ru
Sun Nov 24 07:49:43 PST 2013
On Sunday, 24 November 2013 at 15:35:40 UTC, bearophile wrote:
> 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
Yes, it is confusing. It is especially confusing in an unstable
language with absent adequate spec. For example, I can learn C
namespace rules, but in D case it is useless. Unfortunately what
is right in cases like above depends on what Walter & Andrei
think so we stuck with their opinions on the subject.
(I think emitting at least warning would be good)
More information about the Digitalmars-d
mailing list