Fixed-size arrays and 'null'

Max Samukha spambox at d-coding.com
Thu Nov 12 11:46:07 PST 2009


On Thu, 12 Nov 2009 13:53:13 -0500, bearophile
<bearophileHUGS at lycos.com> wrote:

>Max Samukha:
>
>> What's the advantage?
>
>null is for a pointer/reference. A dynamic array in D is a struct. 

Yes, but dynamic arrays in D are reference types (almost) and array
references (doesn't matter whether they are bare pointers or fat
references) can be tested for nullness and set to null. Like it or
not, there is a distinction between a null array and an empty array,
so I would prefer to use 'null' wherever I want to say 'null array
reference', meaning the struct's ptr member is definitely null.

> [] looks much better to denote an empty array-struct.
>
>Bye,
>bearophile
 



More information about the Digitalmars-d mailing list