[Issue 4733] Possible bugs caused by dynamic arrays in boolean evaluation context

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 27 02:37:19 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=4733



--- Comment #14 from rswhite4 at googlemail.com 2013-11-27 02:37:17 PST ---
(In reply to comment #13)
> (In reply to comment #12)
> > (In reply to comment #11)
> > > (In reply to comment #8)
> > > > Or simply: use arr.length != 0
> > > 
> > > That is not the same as `if (arr)`, and I don't want this to make people
> > > accidentally break their code.
> > 
> > No need to talk to me twice. Then !arr.length. That is the same as
> > std.array.empty and it saves you the import.
> 
> `if (!arr.length) is the same as `if (array.length != 0), and neither are the
> same as `if (arr)`, which expands to `if (arr.ptr)`.

I never said that it is the same. But it's the same as std.array.empty and
saves you the import. That's all.

https://github.com/D-Programming-Language/phobos/blob/master/std/array.d#L41

I would prefer that the warning consider arr.length != 0 more than
std.array.empty. Nothing else. Hope you understand me now.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list