[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:05:47 PST 2013


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


rswhite4 at googlemail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rswhite4 at googlemail.com


--- Comment #8 from rswhite4 at googlemail.com 2013-11-27 02:05:23 PST ---
(In reply to comment #7)
> (In reply to comment #5)
> > Warning:
> > 
> > https://github.com/D-Programming-Language/dmd/pull/2885
> 
> The new warning is:
> 
> warning("converting dynamic arrays to boolean is deprecated, instead use
> array.ptr");
> 
> For normal D programmers the right way to tell if an array (and eventually
> associative array) is empty is with the std.array.empty function, that tests
> the length. You don't want future normal D programmers to start using .ptr
> everywhere they want to test array emptiness.
> 
> So perhaps a better warning is:
> 
> "converting dynamic arrays to boolean is deprecated, instead use
> std.array.empty"
> 
> On the other hand some programmers want really meant to use ".ptr". And some
> programmers want to test "arr.length || arr.ptr" and so on.
> 
> So perhaps an alternative error message is:
> 
> "converting dynamic arrays to boolean is deprecated"

Or simply: use arr.length != 0

-- 
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