Forbid dynamic arrays in boolean evaluation contexts

Steven Schveighoffer schveiguy at yahoo.com
Tue Mar 26 20:05:44 PDT 2013


On Tue, 26 Mar 2013 18:56:07 -0400, Timon Gehr <timon.gehr at gmx.ch> wrote:

> On 03/26/2013 10:31 PM, Vladimir Panteleev wrote:
>> On Tuesday, 26 March 2013 at 17:57:47 UTC, Steven Schveighoffer wrote:
>>> But it definitely is NOT a bug.  Any suggested change would be an
>>> enhancement request.
>>
>> Why do you think it is not a bug? It is inconsistent with "", and what's
>> the point of [] if you can just use "null"?
>
> IOW, what is the point of "null" if you can just use [].

One could say why have null if you can just use T[].init.  It's two names  
for the same thing, not uncommon in programming.

In this case, however, I think handling or allowing [] is good for generic  
code.  The question then becomes what should [] return?  To have it return  
null seems acceptable to me -- the default empty array is null, and null  
behaves quite well as a zero-length array.  The spec allows for it, and  
it's free to use null.

-Steve


More information about the Digitalmars-d mailing list