arrays: if(null == [ ])

Jonathan M Davis jmdavisProg at gmx.com
Tue May 15 12:05:22 PDT 2012


On Tuesday, May 15, 2012 17:35:58 Gor Gyolchanyan wrote:
> Even if it's wrong to move writef to druntime, the toUTFz is still a very
> small word to write.

Using toStringz or toUTFz instead of having string literals be zero-terminated 
would force allocating extra strings (string literals are in an RO portion of 
memory - at least on Linux - so you can't append to them without 
reallocating).

Making it so that string literals weren't null terminated would break a _lot_ 
of code for little-to-no benefit and a definite cost. I really don't see the 
problem with "" being different from cast(string)[] - particularly when the 
fact that "" is non-null is _useful_.

- Jonathan M Davis


More information about the Digitalmars-d mailing list