Debug help - Programming in D - extending tail slice terminates sharing unexpectedly. Page 69, 70

Steven Schveighoffer schveiguy at gmail.com
Tue Oct 21 20:07:48 UTC 2025


On Tuesday, 21 October 2025 at 10:28:52 UTC, Brother Bill wrote:
> On Tuesday, 21 October 2025 at 02:42:07 UTC, monkyyy wrote:
>> On Tuesday, 21 October 2025 at 02:08:41 UTC, Brother Bill 
>> wrote:
>>>
>>> If there are valid cases where breaking sharing is 
>>> intentional and useful, kindly share some of those scenarios.
>>
>> appending a null to a string for toStringz
>
> Do you mean appending an ASCII NUL character 0x00 to a string 
> to make it C language friendly?
>
> Or appending a null pointer to toStringz function?
>
> Not following.

Perhaps Monkyyy means that instead of appending the 0 on an 
existing string, it's better to allocate a new string for it 
instead, because you now must reallocate the original if you 
append to it?

FWIW, this is not what happens in phobos `toStringz`, it just 
appends without concern of this use case.

-Steve


More information about the Digitalmars-d-learn mailing list