Forbid dynamic arrays in boolean evaluation contexts
Timon Gehr
timon.gehr at gmx.ch
Tue Mar 26 01:15:05 PDT 2013
On 03/26/2013 03:21 AM, Vladimir Panteleev wrote:
> ...
>
> I use this feature in the same way that anyone uses a nullable type.
> It's the same distinction between a pointer to struct that is null, or
> that is pointing to an instance containing the struct's .init. It's the
> same distinction between a value type T and the benefits of Nullable!T.
> "null" is usually used to indicate the absence of a value, as opposed to
> an empty value.
>
It is not the same distinction. It is not like that for dynamic arrays!
void main(){ assert(null is []); }
> Although I can see how this can trip up new users of D, personally I
> prefer things to be just the way they are now. That said, I wouldn't be
> against forcing one to write "s is null", if the consensus was that this
> would improve D.
"s.ptr is null", actually
More information about the Digitalmars-d
mailing list