Making all strings UTF ranges has some risk of WTF
Simen kjaeraas
simen.kjaras at gmail.com
Thu Feb 4 06:36:49 PST 2010
Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
>
> What can be done about that? I see a number of solutions:
>
> (a) Do not operate the change at all.
>
> (b) Operate the change and mention that in range algorithms you should
> check hasLength and only then use "length" under the assumption that it
> really means "elements count".
>
> (c) Deprecate the name .length for UTF-8 and UTF-16 strings, and define
> a different name for that. Any other name (codeUnits, codes etc.) would
> do. The entire point is to not make algorithms believe strings have a
> .length property.
>
> (d) Have std.range define a distinct property called e.g. "count" and
> then specialize it appropriately. Then change all references to .length
> in std.algorithm and elsewhere to .count.
>
> What would you do? Any ideas are welcome.
Of the above, I feel (b) is the correct solution, and I understand it
has already been implemented in svn.
--
Simen
More information about the Digitalmars-d
mailing list