More complexity creep in Phobos

Olivier FAURE couteaubleu at gmail.com
Mon Apr 1 18:13:55 UTC 2019


On Saturday, 30 March 2019 at 22:31:05 UTC, Andrei Alexandrescu 
wrote:
> We should have one rcstring type that is reference counted, 
> uses UTF8, is not a range, offers ranges (bytes, codepoints, 
> graphemes), and consolidate around it. Algorithms should only 
> use ranges, and whenever someone wants to use an algorithm with 
> a string, they choose the iteration mode that fits the 
> application.

Why?

Strings have the advantage of being extremely simple constructs 
that represent exactly the right abstraction: they're a slice of 
chars, period. They can be scoped, sliced and concatenated just 
like any other range.

Getting rid of auto-decoding would be good, but adding a whole 
new layer of abstraction and special cases on top of it, with a 
dedicated allocation strategy C++ style, seems superfluous at 
best.

Honestly, it sounds like the kind of thing that will make 
reference-counting the new class, where 10 years from now people 
will be told "Yeah, it would be more convenient to do things this 
way, but back when this standard library was written we were 
using reference-counting everywhere, and now we're stuck with it".

tl;dr Keep strings and reference-counting separate.


More information about the Digitalmars-d mailing list