if(arr) now a warning

Iain Buclaw via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 29 01:29:03 PDT 2015


On 29 April 2015 at 06:38, Steven Schveighoffer via Digitalmars-d
<digitalmars-d at puremagic.com> wrote:
> FYI, Andrei and Walter are reversing this change barring any new evidence
> it's helpful to people. Please speak up if you disagree.
>
> https://github.com/D-Programming-Language/dmd/pull/2885#issuecomment-97299912
>
> -Steve

I disagree, and I would extend my thoughts to say that I don't think
that the change is enough.  We should also be warning on delegates and
associative arrays too!

if (arr)  // Implicitly converted to (arr.ptr | arr.length) != 0
if (dg)  // Implicitly converted to (dg.ptr | dg.funcptr) != 0
if (aa)  // Implicitly converted to (aa.ptr != null)

Iain


More information about the Digitalmars-d mailing list