Checking if a string is null

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Jul 26 00:16:40 PDT 2007


Oskar Linde wrote:
> Manfred Nowak wrote:
>> Frits van Bommel wrote
>>
>>> But the fact of the matter is, 'T[] x = null;' reserves space for
>>> the .length and sets it to 0. If you have a suggestion for a
>>> different value to put there, by all means make it.
>>
>> Suggestion:
>> After `T[] x= null;' `x.length == size_t.max' and `x.ptr == null', 
>> i.e.  `size_t.max' will no more be a valid length for an array.
> 
> Uhu... Why whould a slice of the full addressable memory space be a good 
> initialization value?

It's not the *full* addressable memory space for 1-byte types (the last 
byte of the address space has an address equal to .ptr(0) + 
.length(size_t.max), which isn't a member of the array) and it's more 
than the address space for bigger types (though I guess it does indeed 
cover the entire address space, possibly several times over, due to 
wraparound on overflow...).
</pedantic>


More information about the Digitalmars-d-learn mailing list