Checking if a string is null
Don Clugston
dac at nospam.com.au
Wed Jul 25 13:07:15 PDT 2007
Regan Heath wrote:
>>> The only thing that should compare equal to null is null. Likewise
>>> an empty array should only compare equal to another empty array.
>> >
>> > My reasoning for this is consistency, see at end.
>>
>> Since null arrays have length 0, they *are* empty arrays :P.
>
> I can't tell in which way you're joking so I'm just going to come out
> with...
>
> The length of something be it an array, a car, a <insert thing> is
> totally independant of whether it exists (though a non-existant item
> cannot have a length).
>
> It either exists or it does not. If it exists, it has a length which
> may or may not be zero.
>
> Something which exists cannot be equal to something which doesn't.
I don't think that's really what's happening here.
Consider vectors. If a vector has a length of zero, the direction doesn't exist.
Take two arbitrary vectors with different directions, a and b.
a*0 == b*0, even though the direction of a is completely different to that of b.
This is the same model which is being used for arrays; if the .length is zero,
the .ptr is irrelevant.
More information about the Digitalmars-d-learn
mailing list