More complexity creep in Phobos
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Apr 1 18:46:54 UTC 2019
On 4/1/19 2:13 PM, Olivier FAURE wrote:
> tl;dr Keep strings and reference-counting separate.
You can't do that. New strings are created frequently by concatenation,
they're best thought of as units - like int. They need to handle their
own allocation, there's no two ways about it.
Autodecoding hurts "half" of the users - those who don't need it for the
task. De-encapsulating string as an unstructured slice hurts the other
"half" - those who need things like Unicode semantics, simple string
manipulation, and good use of memory.
The view that strings must be char[] and that that's the "simple" choice
has been a disaster for D. (I believe I have started to convince Walter
of that.) It's simple like Go is simple - forcing complexity realities
on users. Incomparably larger than autodecoding. It has forced virtually
all string-processing code in D to use the garbage collector. Immutable
was a short of adrenaline that prolonged the lifetime of strings by ten
years. Before that, having unstructured strings that were also weirdly
mutable was a double disaster.
We must have a UTF8 reference counted string that assists built-in
literals of type immutable(char)[] and rally the entire language
ecosystem around those.
More information about the Digitalmars-d
mailing list