The Case Against Autodecode

ag0aep6g via Digitalmars-d digitalmars-d at puremagic.com
Mon May 30 07:56:36 PDT 2016


On 05/30/2016 04:35 PM, Seb wrote:
> That's a great idea - the compiler should also issue deprecation
> warnings when I try to do things like:
>
> string a  = "你好";
>
> a[1]; // deprecation: direct access to a Unicode string is highly
> error-prone. Please specify the type of access. More details (shortlink)
>
> a[1] = "b"; // deprecation: direct index assignment to a Unicode string
> is ...
>
> a.length; // deprecation: a Unicode string has multiple definitions of
> length. Please specify your iteration (...). More details (shortlink)
>
> ...
>
> Btw should a[] be an alias for `byCodeUnit` or also trigger a warning?

All this is only sensible when we move to a dedicated string type that's 
not just an alias of `immutable(char)[]`.

`immutable(char)[]` explicitly is an array of code units. It would not 
be acceptable, in my opinion, if the normal array syntax got broken for it.


More information about the Digitalmars-d mailing list