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

Benjamin G benjamin.garrigues at gmail.com
Sun Oct 15 08:33:15 CDT 2017

On Sat, Oct 14, 2017 at 3:45 AM, Brent Royal-Gordon via swift-evolution <
swift-evolution at swift.org> wrote:

> > On Oct 12, 2017, at 9:57 PM, Kevin Nattinger via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> > That is reflected in the fact that over half the methods in the main
> Sequence definition* make no sense and are not well-defined unless there is
> a well-defined order to the sequence itself. What does it even mean to
> `dropFirst()` in a Set?
> It means to skip the first element the set would normally have given you.
> Which element this will be may be arbitrary, but this is still not useless:
>     set.dropFirst().reduce(set.first!, …)

Do we have the guarantee that set.dropFirst() is going to return the same
element as set.first! ?

I don't understand how you can build generic algorithms over Sequence using
first() and last() that work if the protocol itself doesn't give any
guarantee about ordering.. Unless "first" and "last" both mean "any"...

> Even elementsEqual(_:) does tell you something potentially valuable:
> Whether two instances will end up giving the same result when processed by
> an ordering-sensitive algorithm.
> We should change the name to something like orderEquals(_:), and maybe
> change the lexicographicallyPrecedes(_:) method to something analogous like
> orderPrecedes(_:), and then be done with it.
> --
> Brent Royal-Gordon
> Sent from my iPhone
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20171015/5d07df96/attachment.html>

More information about the swift-evolution mailing list