if(arr) now a warning

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 10 01:54:51 PDT 2015


On Friday, 10 April 2015 at 08:38:00 UTC, 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.

Well every time anyone has:

arr[n..m]

where n == m, for a start. That includes every slice that's been 
popFront'd to exhaustion.


More information about the Digitalmars-d mailing list