Forbid dynamic arrays in boolean evaluation contexts

Steven Schveighoffer schveiguy at yahoo.com
Mon Mar 25 18:57:09 PDT 2013


On Mon, 25 Mar 2013 17:28:51 -0400, Vladimir Panteleev  
<vladimir at thecybershadow.net> wrote:

> On Monday, 25 March 2013 at 14:46:27 UTC, Steven Schveighoffer wrote:
>> I would favor just changing the behavior.
>
> That would silently break my code.

It would seem incomplete not to have if(arr) work, and the way it works  
now is very error prone.

You would have to change your code either way.  Deprecating than  
reintroducing seems gratuitous to me.  Most people do not use if(arr) to  
check for array pointer when if(arr.ptr) is more descriptive.

How much do you use this "feature"?  Can they simply be replaced with  
if(arr.ptr)? or are they more of the type Jacob has with if(auto a =  
getArray())?  I'm trying to get a feel for how much breakage this causes,  
as I typically do not use that construct.

-Steve


More information about the Digitalmars-d mailing list