Sent from my iPad

> On Jan 23, 2017, at 9:50 AM, Ben Cohen <[email protected]> wrote:
> 
> 
>> On Jan 22, 2017, at 9:54 PM, Félix Cloutier <[email protected]> wrote:
>> 
>> 
>>>> doesn't necessarily mean that ignoring that case is the right thing to do. 
>>>> In fact, it means that Unicode won't do anything to protect programs 
>>>> against these, and if Swift doesn't, chances are that no one will. 
>>>> Isolated combining characters break a number of expectations that 
>>>> developers could reasonably have:
>>>> 
>>>> (a + b).count == a.count + b.count
>>>> (a + b).startsWith(a)
>>>> (a + b).endsWith(b)
>>>> (a + b).find(a) // or .find(b)
>>>> 
>>>> Of course, this can be documented, but people want easy, and documentation 
>>>> is hard.
>>> 
> These rules, while intuitive for some collections like Array, are not 
> documented requirements of RangeReplaceableCollection & Equatable on which 
> they rely.

While I agree wholeheartedly with the gist Ben's response here, I feel the need 
to clarify one thing:

The documentation doesn't have to spell out every possible law (theorem) 
explicitly as long as it is implied by what is documented (the axioms).  For 
example,

    a.startsWith(a)

is a law, and it's implied by this documentation:

func starts(with:)
Returns a Boolean value indicating whether the initial elements of the sequence 
are the same as the elements in another sequence.

If for some reason the rules above are not the inevitable consequence of 
documented semantics of RangeReplaceableCollection where Iterator.Element : 
Equatable, that is a bug.  
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to