[swift-evolution] [Draft] Rename Sequence.elementsEqual
xiaodi.wu at gmail.com
Mon Oct 16 00:22:11 CDT 2017
On Sun, Oct 15, 2017 at 11:59 PM, Thorsten Seitz <tseitz42 at icloud.com>
> Am 16.10.2017 um 00:46 schrieb Xiaodi Wu <xiaodi.wu at gmail.com>:
> On Sun, Oct 15, 2017 at 2:39 PM, Kevin Nattinger <swift at nattinger.net>
>> Swift's Sequence protocol does not require the order of iteration to
>> "convey any meaning"; it doesn't even require it to be deterministic.
>> And that’s EXACTLY why none of the functions on Sequence should rely on
>> the order conveying meaning. `ElementsEqual` (for example) DOES rely on
>> the order of iteration conveying a meaning not required by the protocol,
>> and renaming it `lexicographicallyEquals` does not change that fact. Either
>> Sequence needs to require a meaningful order or `elementsEqual` should be
>> moved to a protocol that does.
> What's your basis for saying that `elementsEqual` requires orders of
> iteration that "convey a meaning"? It merely answers the question of
> whether iterating over `a` is substitutable for iterating over `b`, a
> question applicable to instances of any type which offers iterated access.
> As Set has no intrinsic order of elements just imagine it was implemented
> to have each iterator created on it to iterate in a random order. This
> would satisfy the Sequence protocol (or rather its Iterable part hich
> should be split off) and clearly show that the order is meaningless for
As I wrote above, Set cannot use a different iteration order for each
iterator because it conforms to `Collection`, thereby guaranteeing a
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution