if(arr) now a warning

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 10 05:51:54 PDT 2015


On 4/10/15 5:35 AM, John Colvin wrote:
>
> As others have mentioned, why not make if(arr) be equivalent to
> if(arr.length)? It seems that's what everyone actually wants when they
> type it.

Some code legitimately uses if(arr) to check the pointer (see link to 
the tools change that I posted originally). This code would compile, but 
silently change semantic. Such breaking changes are the worst kind, and 
should not be allowed.

In all honesty, I don't really care if we ever reintroduce if(arr) 
again, typing if(arr.length) is not that bad, and clarifies the intent.

-Steve


More information about the Digitalmars-d mailing list