on Tue May 30 2017, Michael Ilseman <milseman-AT-apple.com> wrote:

>> On May 27, 2017, at 10:40 AM, Dave Abrahams via swift-evolution 
>> <swift-evolution@swift.org> wrote:
>> 
>> 
>> An index that does not fall on an exact boundary in a given `String`
>> or `Substring` view will be “rounded down” to the nearest boundary
>> when used for slicing or range replacement.  So, for example,
>> 
>
> What about normal subscript? I.e. what would the following print?
>
> print(s[s.unicodeScalars.indices.dropFirst().first!]) // “é”, or just
> the combining scalar?

I am proposing that it would be “é”

>
>
> Would unifying under the same type require that indices be less
> stateful than they currently are?

No; it's just a matter of unifying the states (in an enum).  You can
look at the implementation in https://github.com/apple/swift/pull/9806
for details.

>
>> ```swift
>> let s = "e\u{301}galite\u{301}"                          // "égalité"
>> print(s[s.unicodeScalars.indices.dropFirst().first!...]) // “égalité"
>> print(s[..<s.unicodeScalars.indices.last!])              // "égalit"
>> ```

-- 
-Dave
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to