[swift-evolution] [Draft] Rename Sequence.elementsEqual
Thorsten Seitz
tseitz42 at icloud.com
Wed Oct 18 18:18:36 CDT 2017
> Am 19.10.2017 um 01:13 schrieb Adam Kemp <adam_kemp at apple.com>:
>
>
>> On Oct 18, 2017, at 3:38 PM, Thorsten Seitz <tseitz42 at icloud.com <mailto:tseitz42 at icloud.com>> wrote:
>>
>> Now this is not production code (hopefully) but it demonstrates the problem.
>
> A single StackOverflow post is not convincing evidence of a problem that leads to many real-world bugs. No one here would dispute that people can get confused. That’s why there’s a proposal in the first place. The proposal would have prevented this example merely by making the name clearer.
>
> This is at best evidence that a name change is needed. It’s not evidence that we should make large changes to the library and language.
>
>> How will I know if the code behind a generic function taking a Sequence as argument will internally use `elementsEqual` so that I cannot use a Set as argument?
>
> More generally, how would you know if someone wrote a function that takes an unordered sequence and then writes an algorithm that relies on the order anyway? Splitting the Sequence protocol can’t guarantee you won’t have those kind of bugs. If the semantics of the function are not clear then that’s a naming problem or a library design problem. That’s why the proposal is to fix the name so that it’s clear what it actually does.
I agree, it is a naming problem or a library design problem. That’s why I propose to have different names for both notions (unordered and ordered), so that it’s clear what the contract of the whole type is (and not just that of a single method).
-Thorsten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171019/c2cc8410/attachment.html>
More information about the swift-evolution
mailing list