[swift-evolution] [Draft] Rename Sequence.elementsEqual

Adam Kemp adam_kemp at apple.com
Wed Oct 18 18:13:43 CDT 2017

> On Oct 18, 2017, at 3:38 PM, Thorsten Seitz <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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171018/5e7b4972/attachment.html>

More information about the swift-evolution mailing list