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

Adam Kemp adam_kemp at apple.com
Mon Oct 16 17:15:32 CDT 2017

> On Oct 16, 2017, at 3:08 PM, Thorsten Seitz <tseitz42 at icloud.com> wrote:
>> 2. It’s generally useful to be able to ask if two objects that you can iterate over are equal by comparing the elements in the order that they’re iterated over.
> Here I disagree. This operation only makes sense if the iteration order has underlying well defined semantics. Otherwise the result of that operation will be a random value, depending on the undefined order. I argue that this is never useful. That is why I am asking for a use case for that.

I deliberately didn’t specify in either of these cases whether the thing was ordered or not. I’m not disputing that this only makes sense for ordered things. I’m merely pointing out that making that distinction is impractical for other reasons.

> There are several solutions for this, e.g. covariant redefinition of the result type to be ordered in an ordered subclass, or more sophisticated solutions which could even allow to chose the result type if required to be different from a default.
> The latter would allow e.g. mapping over a Set to commonly result in a generic Iterable but in some cases it might also result in another Set. The same holds for mapping over an ordered collection like an Array. The result might commonly be an array but it might also be a Set or something else.
> Swift currently lacks the necessary capabilities in the type system to achieve this, though, so we would have to stay with the current solution that `map` always returns an Array (at least for the moment) — which already is not very satisfactory in itself.

Now you’re inventing new language features in order to support your proposed solution to a problem that I still have seen no evidence to support being a significant source of real bugs. And those new language features would still result in a library and language that is harder to use than before. This is not a convincing argument for making a change.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171016/1d359859/attachment.html>

More information about the swift-evolution mailing list