Checking if a string is null

Derek Parnell derek at psyc.ward
Wed Jul 25 23:46:58 PDT 2007

On Thu, 26 Jul 2007 08:37:13 +0200, 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?

Maybe x.ptr = size_t.max and x.length = size_t.max might be useful
representation of a null array as it is an illegal RAM reference otherwise.
But I know, its too late now and probably too expensive at run-time to

>> This is a hack to avoid some overhead in some places, but may introduce  
>> more overhead in other places.
> This entire discussion is trying to make todays T[] -- a slice type with 
> value semantics and some provisions for making it behave as an array in 
> some cases -- into a pure array type with a well defined null. You can't 
> do that without breaking its slice semantics. A much better suggestion 
> is Walter's T[new]. Make T[] remain the slice type it is today and make 
> a distinct array type (preferably a by-reference type).

You may very well be correct.

Derek Parnell
Melbourne, Australia
"Down with mediocrity!"

More information about the Digitalmars-d-learn mailing list