Checking if a string is null
oskar.lindeREM at OVEgmail.com
Wed Jul 25 23:37:13 PDT 2007
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.
> 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
> 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).
> Note: after `T x= null;' `x' holds an untyped array and so `y= x;'
> should be a legal assignment for every `y' declared as `U y;' for
> some type `U'---duck and run.
So you are proposing adding runtime type errors? :P
More information about the Digitalmars-d-learn