C is Brittle D is Plastic
Kapendev
alexandroskapretsos at gmail.com
Fri Apr 3 14:51:00 UTC 2026
On Friday, 3 April 2026 at 12:20:19 UTC, Quirin Schroll wrote:
> The worst part about D’s strings are auto-decoding and that
> literals include a secret zero past the end without you asking
> for it.
>
> About the last thing, maybe in the next Edition, we can have
> `""z` strings that request a secret zero and only add the zero
> if a non-z string is used to initialize an `immutable(char)*`
> or `const(char)*` (or make it an error to omit the `z` in that
> case). That would allow for some compression to be done by the
> compiler: If you have strings in your code like `"BC"` and
> `"ABCD"`, it could just re-use segment. With the secret zero,
> it can only re-use suffixes.
It should be the other way around if that ever becomes a thing.
The defaults being safe with a zero at the end and the unsafe
version requiring an explicit symbol thing.
More information about the Digitalmars-d
mailing list