C is Brittle D is Plastic
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Fri Apr 3 23:32:12 UTC 2026
On 04/04/2026 6:27 AM, Walter Bright wrote:
> I agree with everything you wrote, except:
>
>> The worst part about D’s strings are auto-decoding
>
> That's a Phobos-only feature, and will be dumped for the next Phobos.
>
>> and that literals include a secret zero past the end without you
>> asking for it.
>
> I think it's quite nice! It makes using string literals assigned to
> pointers (or implicitly converted to pointers) work seamlessly with C.
>
> Also,
>
> ```d
> pragma(msg,"hello".length);
>
> immutable string abc = "hello";
> pragma(msg, abc.length);
> ```
> prints:
>
> 5Lu
> 5LU
>
> How is it a problem?
Prefix string interning, can't optimize the text segment so only one
copy of a given sequence of bytes is present.
As in: AB, ABC, ABCD
Only needs ABCD in text segment.
Whereas: AB\0, ABC\0, ABCD\0
Can't be optimized down to just ABCD\0.
Idk how much that matters, but that was the argument.
More information about the Digitalmars-d
mailing list