The more interesting question

Timon Gehr timon.gehr at gmx.ch
Tue May 15 11:35:21 PDT 2012


On 05/15/2012 06:45 PM, deadalnix wrote:
> Le 15/05/2012 17:51, Christophe a écrit :
>> deadalnix , dans le message (digitalmars.D:167404), a écrit :
>>> This looks to me like a bad practice. C string and D string are
>>> different beasts, and we have toStringz .
>>
>> C string and D string are different, but it's not a bad idea to have
>> string *literals* that works for both C and D strings, otherwise using
>> printf will lead to a bug each time the programmer forget the trailing
>> \0.
>>
>>> It is kind of dumb to create a WAT is the language because druntime dev
>>> did mistakes. It have to be fixed.
>>
>> You can't rely on an empty string to be null since you must be able to
>> reserve place at the end of the array, and or the string could be the
>> result of poping a full string.
>
> This is why I stated put null when the string length is SET to 0, not
> when it is 0.
>
> So it is nulled when I create an empty slice, or do arr.length = 0

Might as well start Microsoft Flight Simulator when the length is set to 
9797.

If you want to clear the contents of the array, use arr=null or arr=[].


More information about the Digitalmars-d mailing list