On Tue, 17 Oct 2017 at 21:00, Jonathan Hull via swift-evolution <
swift-evolution@swift.org> wrote:

>
> On Oct 17, 2017, at 11:47 AM, Michael Ilseman via swift-evolution <
> swift-evolution@swift.org> wrote:
>
> `==` conveys substitutability of the two Sequences. This does not
> necessarily entail anything about their elements, how those elements are
> ordered, etc., it just means two Sequences are substitutable.
> `elementsEqual` means that the two Sequences produce substitutable
> elements. These are different concepts and both are independently useful.
>
>
> I agree that ‘==‘ conveys substitutability.  Here is the issue:
>
> let a = Set([1,2,3,4,5])
> let b = Set([5,4,3,2,1])
>
> a == b //True, they are substitutable
>
> [1,2,3,4,5].elementsEqual(a) //True
> [1,2,3,4,5].elementsEqual(b) //False… I guess they weren’t actually
> substitutable after all
>
>
> Thanks,
> Jon
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>

I read along with most of the thread and like to add one thing. Maybe it’s
not the right way to look at things, but I see protocol extensions as being
part of any type that conforms to the protocol. As it is now, code
completion on a Set will present me with the elementsEqual function, which
in my view is misleading, since it cannot be used in any useful way with a
Set.

By renaming elementsEqual we might be able to make it less misleading, but
it will always be a useless function that is part of the Set namespace (or
Dictionary for that matter).

I don’t know what the best solution would be, but to me it feels like
distinguishing between Iterable and Sequence, or Ordered and Unordered
makes sense, and it might be good to at least investigate what the impact
would be.

Regards,
/Manolo
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to