On Tuesday, 26 March 2013 at 08:15:05 UTC, Timon Gehr wrote:
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 []); }
[] (the literal) has .ptr as null. That may or may not be a bug.
To create a non-null empty array, you have to use something like
(new uint[1])[0..0]. The "" literal does not have this problem.
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
The distinction being the case with a non-empty slice starting at
address 0?