array !is null fails

Frits van Bommel fvbommel at
Tue Feb 13 09:34:35 PST 2007

BCS wrote:
> Reply to Jarrett,
>> "BCS" <ao at> wrote in message
>> news:ce0a334373d48c91d12a1b9c0ec at
>>> What good is the (array !is null) if it doesn't tell you when the
>>> pointer is null?
>> Well if you want to see if the pointer is null then use "if(array.ptr
>> is null)".  Though I'll agree with you that the discontinuity between
>> zero-length null pointer arrays and more-than-zero-length null pointer
>> arrays is a bit odd.
> What else could be null? I don't see anything else that it could mean 
> other than "is the pointer null".

'null', when interpreted as an array, is an _empty_ array with the 
pointer being null.

This allows it to be a reasonable default initializer for dynamic 
arrays, and means (arr == null) checks whether the array is empty.

More information about the Digitalmars-d-learn mailing list