The Nullity Of strings and Its Meaning

kdevel via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 9 11:55:51 PDT 2017


On Sunday, 9 July 2017 at 15:10:56 UTC, ag0aep6g wrote:
> On 07/09/2017 03:51 PM, kdevel wrote:
>> On Sunday, 9 July 2017 at 10:32:23 UTC, ag0aep6g wrote:

[...]

> A null char* is not a proper C string.

A C string is a sequence of storage units containing legitimate 
character values of which the last one is the NUL character.

> It doesn't have length 0. It has no length.

In C a NULL ptr does not refer to anything including not to a C 
string.

> A C function can't return a null char* when it's supposed to 
> return an empty string.

That is true. And this it what mislead me thinking that D behaves 
the same.

> But a D function can return a null char[] in that case.

Yes, it can obviously return one of the two representations of 
the empty D string.

Stefan


More information about the Digitalmars-d-learn mailing list