April 10, 2015
On Friday, 10 April 2015 at 10:30:13 UTC, Daniel Murphy wrote:
> if (arr.length) is just as clear, and the same thing.

I agree, people should just use arr.length. I would leave it as it is now, that is forever warning on if (arr).
April 10, 2015
Martin Krejcirik:

> I agree, people should just use arr.length.

People should probably use "arr.empty".

Bye,
bearophile
April 10, 2015
"Martin Krejcirik"  wrote in message news:zcyuydcpyfjrbojzjusg@forum.dlang.org...

> I agree, people should just use arr.length. I would leave it as it is now, that is forever warning on if (arr).

Yeah, even if we never get to deprecation/error/change of semantics the warning will be an improvement. 

April 10, 2015
On Thursday, 9 April 2015 at 20:59:00 UTC, Steven Schveighoffer wrote:
> What do you think?

Well, that's a pretty one-sided description of the argument!

I would like to invite anyone interested in this proposal to try compiling their own code with the latest compiler, and see how much busywork this creates vs. how much real bugs this identifies.

The tools repository is occasionally used as a guinea pig for breaking changes. Consider the amount of changes needed here, as an example:

https://github.com/D-Programming-Language/tools/pull/166/files

(Disclaimer: part of this is my own code, and I consider the distinction between null and empty arrays an obvious and useful principle.)

IMHO, this is not something worth breaking the language over.
April 10, 2015
On Friday, 10 April 2015 at 11:18:16 UTC, bearophile wrote:
> Martin Krejcirik:
>
>> I agree, people should just use arr.length.
>
> People should probably use "arr.empty".
>
> Bye,
> bearophile

Comes to the same thing: https://github.com/D-Programming-Language/phobos/blob/master/std/range/primitives.d#L1957
April 10, 2015
On 2015-04-10 13:18, bearophile wrote:
> People should probably use "arr.empty".

We should have an opposite of "empty". Something like "arr.any" or similar.

-- 
/Jacob Carlborg
April 10, 2015
On Friday, 10 April 2015 at 11:39:59 UTC, Vladimir Panteleev wrote:
> https://github.com/D-Programming-Language/tools/pull/166/files
> I don't know the code well enough to know if arr != null would be more appropriate.

It's probably a nitpick, I like arr!=null expression a lot, but currently compiler generates a horrible code for it: ldc generates comparison with typeinfos, and dmd inlines whole memcmp among other things instead of converting it to just arr.length!=0.
April 10, 2015
"Kagamin"  wrote in message news:pdxfmrxrtfcwextsankd@forum.dlang.org...

> It's probably a nitpick, I like arr!=null expression a lot, but currently compiler generates a horrible code for it: ldc generates comparison with typeinfos, and dmd inlines whole memcmp among other things instead of converting it to just arr.length!=0.

Things like this are worth reporting. https://issues.dlang.org/show_bug.cgi?id=14436 

April 10, 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
April 10, 2015
On Friday, 10 April 2015 at 10:14:43 UTC, Martin Nowak wrote:
> On Friday, 10 April 2015 at 09:27:56 UTC, w0rp wrote:
>> If we need a deprecation path, we can do it. We just warn about if (arr) for a while, so you are told to use if(arr.length == 0) or if (arr.ptr is null) for a while, then we change the behaviour in another release.
>
> That's kind of the roadmap, though we'd need to wait quite a while until we can reuse it.
> I've been thinking about moving std.array.empty to object. Then that could more easily become the replacement idiom.
>
> if (arr) -> if (!arr.empty)
>
> It's much clearer and also what you need to write when you work with ranges.

I like this. I put in a .empty property for the hashmaps and sets I wrote which uses .length == 0.

if (arr) is a problem for new D programmers, who will write it probably expecting it to be the same as if (arr.length == 0). Any struct type in D can behave the same way by implementing an overload for cast(bool).