Proposal for fixing dchar ranges
John Colvin
john.loughran.colvin at gmail.com
Mon Mar 10 12:30:00 PDT 2014
On Monday, 10 March 2014 at 18:09:51 UTC, Steven Schveighoffer
wrote:
> On Mon, 10 Mar 2014 14:01:45 -0400, John Colvin
> <john.loughran.colvin at gmail.com> wrote:
>
>> On Monday, 10 March 2014 at 17:54:49 UTC, Steven Schveighoffer
>> wrote:
>>> On Mon, 10 Mar 2014 13:06:08 -0400, Brad Anderson
>>> <eco at gnuk.net> wrote:
>>>
>>>> It seems like this would be an even bigger breaking change
>>>> than Walter's proposal though (right or wrong, slicing
>>>> strings is very common).
>>>
>>> You're the second person to mention that, I was not planning
>>> on disabling string slicing. Just random access to individual
>>> chars, and probably .length.
>>>
>>> -Steve
>>
>> How is slicing any better than indexing?
>
> Because one can slice out a multi-code-unit code point, one
> cannot access it via index. Strings would be horribly crippled
> without slicing. Without indexing, they are fine.
>
> A possibility is to allow index, but actually decode the code
> point at that index (error on invalid index). That might
> actually be the correct mechanism.
>
> -Steve
In order to be correct, both require exactly the same knowledge:
The beginning of a code point, followed by the end of a code
point. In the indexing case they just happen to be the same
code-point and happen to be one code unit from each other. I
don't see how one is any more or less errror-prone or
fundamentally wrong than the other.
I do understand that slicing is more important however.
More information about the Digitalmars-d
mailing list