std.experimental.collections.rcstring and its integration in Phobos

Seb seb at wilzba.ch
Tue Jul 17 17:28:19 UTC 2018


On Tuesday, 17 July 2018 at 16:58:37 UTC, Jonathan M Davis wrote:
> On Tuesday, July 17, 2018 15:21:30 Seb via Digitalmars-d wrote:
>> [...]
>
> If it's not a range by default, why would you expect _anything_ 
> which operates on ranges to work with rcstring directly? IMHO, 
> if it's not a range, then range-based functions shouldn't work 
> with it, and I don't see how they even _can_ work with it 
> unless you assume code units, or code points, or graphemes as 
> the default. If it's designed to not be a range, then it should 
> be up to the programmer to call the appropriate function on it 
> to get the appropriate range type for a particular use case, in 
> which case, you really shouldn't need to add much of any 
> overloads for it.
>
> - Jonathan M Davis

Well, there are few cases where the range type doesn't matter and 
one can simply compare bytes, e.g.

equal (e.g. "ä" == "ä" <=> [195, 164] == [195, 164])
commonPrefix
find
...

Of course this assumes that there's no normalization necessary, 
but the current auto-decoding assumes this too.


More information about the Digitalmars-d mailing list