Someone should tell him about D...
Steven Schveighoffer
schveiguy at gmail.com
Fri Jun 3 20:34:41 UTC 2022
On 6/3/22 4:12 PM, IGotD- wrote:
> When it comes to strings? Depends what you are doing and how you are
> doing it. C++ made a strange decision to include the null terminator at
> the end of the strings even if it isn't really necessary. The result is
> that you cannot slice strings and can lead to unnecessary deep copies.
> In order avoid this C++ invented string_view and associated literals.
> Now you suddenly have two types of strings and if you make an API you
> might have to support both string and string_view. This is one of the
> crazy things with "modern C++". Still it is more user friendly than the
> old C library strings which also are prone to buffer overflows.
>
> D in this case did the right choice not including the null terminator so
> that you can slice strings all you want and no extra string view.
D almost had 2 types for arrays, one that would allow resizing and
another that would just be a slice.
The point was to solve the stomping problem. But we fixed it a different
way.
Feast your eyes!
https://forum.dlang.org/post/h5nbj3$17is$1@digitalmars.com
-Steve
More information about the Digitalmars-d
mailing list