if(arr) now a warning

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


On 4/10/15 4:38 AM, Jacob Carlborg wrote:
> On 2015-04-09 22:59, Steven Schveighoffer wrote:
>
>> As usual with changes of this nature, there are differing opinions, and
>> differing styles. I personally never use null as a special value for an
>> array, but others do. They use if(arr) to actually mean if(arr.ptr). For
>> these cases, the update will cause some amount of busywork changing
>> these checks.
>>
>> But when updating Phobos to comply with this change, we found several
>> actual incorrect usages. So I think the change is worth it, and not much
>> busywork. YMMV.
>>
>> What do you think?
>
> I'm wondering how often in practice .ptr is not null but the array is
> empty.
>

assert("".ptr);

-Steve


More information about the Digitalmars-d mailing list