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

2017-10-16 Thread Benjamin Garrigues via swift-evolution
> Le 16 oct. 2017 à 07:20, Xiaodi Wu via swift-evolution > a écrit : > >> On Sun, Oct 15, 2017 at 11:57 PM, Thorsten Seitz wrote: >> >> >>> Am 16.10.2017 um 00:41 schrieb Xiaodi Wu via swift-evolution >>> : >>> >>> On Sun, Oct 15, 2017 at 2:32 PM, Kevin Nattinger >>> wrote: > […] >>

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

2017-10-16 Thread Jonathan Hull via swift-evolution
> On Oct 15, 2017, at 9:58 PM, Xiaodi Wu wrote: > > On Sun, Oct 15, 2017 at 8:51 PM, Jonathan Hull > wrote: > >> On Oct 14, 2017, at 10:48 PM, Xiaodi Wu > > wrote: That ordering can be arbitrary, but it shouldn’t leak internal repr

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
>> Am 16.10.2017 um 07:19 schrieb Xiaodi Wu : >> >> On Sun, Oct 15, 2017 at 11:57 PM, Thorsten Seitz wrote: >> >> >>> Am 16.10.2017 um 00:41 schrieb Xiaodi Wu via swift-evolution >>> : >>> >>> On Sun, Oct 15, 2017 at 2:32 PM, Kevin Nattinger >>> wrote: > […] > Sets, as a mathemati

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

2017-10-16 Thread Xiaodi Wu via swift-evolution
On Mon, Oct 16, 2017 at 05:48 Jonathan Hull wrote: > > On Oct 15, 2017, at 9:58 PM, Xiaodi Wu wrote: > > On Sun, Oct 15, 2017 at 8:51 PM, Jonathan Hull wrote: > >> >> On Oct 14, 2017, at 10:48 PM, Xiaodi Wu wrote: >> >>> That ordering can be arbitrary, but it shouldn’t leak internal repr

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

2017-10-16 Thread David Sweeris via swift-evolution
> On Oct 16, 2017, at 07:20, Xiaodi Wu via swift-evolution > wrote: > > >> On Mon, Oct 16, 2017 at 05:48 Jonathan Hull wrote: >> >>> On Oct 15, 2017, at 9:58 PM, Xiaodi Wu wrote: >>> On Sun, Oct 15, 2017 at 8:51 PM, Jonathan Hull wrote: >> On Oct 14, 2017, at 10:48 PM, Xiao

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

2017-10-16 Thread Jonathan Hull via swift-evolution
> On Oct 16, 2017, at 7:20 AM, Xiaodi Wu wrote: > > To start with, the one you gave as an example at the beginning of this > discussion: Two sets with identical elements which have different internal > storage and thus give different orderings as sequences. You yourself have > argued that th

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

2017-10-16 Thread Michael Ilseman via swift-evolution
> On Oct 16, 2017, at 7:20 AM, Thorsten Seitz via swift-evolution > wrote: > > > > Am 16.10.2017 um 07:19 schrieb Xiaodi Wu >: > >> On Sun, Oct 15, 2017 at 11:57 PM, Thorsten Seitz > > wrote: >> >> >> Am 16.10.2017 um 00:41 schrieb

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

2017-10-16 Thread Michael Ilseman via swift-evolution
> On Oct 16, 2017, at 8:46 AM, David Sweeris via swift-evolution > wrote: > > > On Oct 16, 2017, at 07:20, Xiaodi Wu via swift-evolution > mailto:swift-evolution@swift.org>> wrote: > >> >> On Mon, Oct 16, 2017 at 05:48 Jonathan Hull > > wrote: >> >>> On Oct 15, 2017

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

2017-10-16 Thread Kevin Nattinger via swift-evolution
>> […] >> Set conforming to Collection is even worse than just conforming to Sequence >> as a quote from the documentation shows: "In addition to the operations that >> collections inherit from the Sequence protocol, you gain access to methods >> that depend on accessing an element at a specific

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

2017-10-16 Thread Kevin Nattinger via swift-evolution
>> >> How is the iteration order of an unordered set or dictionary “publicly >> observable”? If either is implemented such that it can asynchronously >> optimize its storage (maybe by rebalancing a tree or merging two >> non-contiguous array segments or something), its iteration order could >>

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

2017-10-16 Thread BJ Homer via swift-evolution
> On Oct 16, 2017, at 8:20 AM, Thorsten Seitz via swift-evolution > wrote: > >> Am 16.10.2017 um 07:19 schrieb Xiaodi Wu > >: > >> What useful generic algorithms would this protocol support that are not >> already possible? > > It would allow expressing generic alg

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

2017-10-16 Thread David Sweeris via swift-evolution
> On Oct 16, 2017, at 09:21, Michael Ilseman wrote: > > > >> On Oct 16, 2017, at 8:46 AM, David Sweeris via swift-evolution >> wrote: >> >> >> On Oct 16, 2017, at 07:20, Xiaodi Wu via swift-evolution >> wrote: >> >>> On Mon, Oct 16, 2017 at 05:48 Jonathan Hull wrote: >

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

2017-10-16 Thread David Sweeris via swift-evolution
> On Oct 16, 2017, at 10:42, BJ Homer via swift-evolution > wrote: > >>> On Oct 16, 2017, at 8:20 AM, Thorsten Seitz via swift-evolution >>> wrote: >>> >>> Am 16.10.2017 um 07:19 schrieb Xiaodi Wu : >> >>> What useful generic algorithms would this protocol support that are not >>> already

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

2017-10-16 Thread Michael Ilseman via swift-evolution
Sets being values are not an implementation detail. They have value semantics, and that is part of the guarantee of the type. This is perhaps the most important concept in the standard library. > On Oct 16, 2017, at 10:27 AM, Kevin Nattinger wrote: > >>> >>> How is the iteration order of an

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

2017-10-16 Thread Michael Ilseman via swift-evolution
A Set has indices because they are useful to use with the type. Regardless of whether Set conforms to Collection, or even Sequence, indices are useful and meaningful for Sets. Even if the entire protocol hierarchy were to be redesigned, Set would provide indices. If Set didn’t implement any prot

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

2017-10-16 Thread Kevin Nattinger via swift-evolution
> On Oct 16, 2017, at 10:43 AM, BJ Homer via swift-evolution > wrote: > >> On Oct 16, 2017, at 8:20 AM, Thorsten Seitz via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >>> Am 16.10.2017 um 07:19 schrieb Xiaodi Wu >> >: >> >>> What useful generic

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
> Am 16.10.2017 um 16:20 schrieb Xiaodi Wu via swift-evolution > : > > > On Mon, Oct 16, 2017 at 05:48 Jonathan Hull > wrote: > >> On Oct 15, 2017, at 9:58 PM, Xiaodi Wu > > wrote: >> >> On Sun, Oct 15, 2017 at 8:51 PM, Jonathan Hull >

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
> Am 16.10.2017 um 17:49 schrieb Jonathan Hull via swift-evolution > : > > >> On Oct 16, 2017, at 7:20 AM, Xiaodi Wu > > wrote: >> >> To start with, the one you gave as an example at the beginning of this >> discussion: Two sets with identical elements which have d

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
> Am 16.10.2017 um 18:19 schrieb Michael Ilseman : > > > >> On Oct 16, 2017, at 7:20 AM, Thorsten Seitz via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >> >> >> Am 16.10.2017 um 07:19 schrieb Xiaodi Wu > >: >> >>> On Sun, Oct 15, 2017 at 11:5

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
> Am 16.10.2017 um 19:42 schrieb BJ Homer : > >> On Oct 16, 2017, at 8:20 AM, Thorsten Seitz via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >>> Am 16.10.2017 um 07:19 schrieb Xiaodi Wu >> >: >> >>> What useful generic algorithms would this proto

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

2017-10-16 Thread Kevin Nattinger via swift-evolution
> On Oct 16, 2017, at 11:23 AM, David Sweeris via swift-evolution > wrote: > > > On Oct 16, 2017, at 10:42, BJ Homer via swift-evolution > mailto:swift-evolution@swift.org>> wrote: > >>> On Oct 16, 2017, at 8:20 AM, Thorsten Seitz via swift-evolution >>> mailto:swift-evolution@swift.org>> w

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

2017-10-16 Thread Xiaodi Wu via swift-evolution
On Mon, Oct 16, 2017 at 14:55 Kevin Nattinger via swift-evolution < swift-evolution@swift.org> wrote: > On Oct 16, 2017, at 11:23 AM, David Sweeris via swift-evolution < > swift-evolution@swift.org> wrote: > > > On Oct 16, 2017, at 10:42, BJ Homer via swift-evolution < > swift-evolution@swift.org>

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

2017-10-16 Thread Xiaodi Wu via swift-evolution
On Mon, Oct 16, 2017 at 10:49 Jonathan Hull wrote: > > On Oct 16, 2017, at 7:20 AM, Xiaodi Wu wrote: > > To start with, the one you gave as an example at the beginning of this >> discussion: Two sets with identical elements which have different internal >> storage and thus give different orderin

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

2017-10-16 Thread Xiaodi Wu via swift-evolution
On Mon, Oct 16, 2017 at 13:15 David Sweeris wrote: > > On Oct 16, 2017, at 09:21, Michael Ilseman wrote: > > > > On Oct 16, 2017, at 8:46 AM, David Sweeris via swift-evolution < > swift-evolution@swift.org> wrote: > > > On Oct 16, 2017, at 07:20, Xiaodi Wu via swift-evolution < > swift-evolution

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

2017-10-16 Thread Kevin Nattinger via swift-evolution
> On Oct 16, 2017, at 1:08 PM, Xiaodi Wu via swift-evolution > wrote: > > > On Mon, Oct 16, 2017 at 13:15 David Sweeris > wrote: > > On Oct 16, 2017, at 09:21, Michael Ilseman > wrote: > >> >> >>> On Oct 16, 2017, at 8:46 AM, David S

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

2017-10-16 Thread Adam Kemp via swift-evolution
> On Oct 16, 2017, at 12:35 PM, Thorsten Seitz via swift-evolution > wrote: > > IMHO `elementsEqual` provides a nice example for a method which only makes > sense on something meaningfully ordered: > What is the use case for `elementsEqual` that works with a Set? There may not be one, but he

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

2017-10-16 Thread Greg Parker via swift-evolution
> On Oct 16, 2017, at 1:08 PM, Xiaodi Wu via swift-evolution > wrote: > > On Mon, Oct 16, 2017 at 13:15 David Sweeris > wrote: > > On Oct 16, 2017, at 09:21, Michael Ilseman > wrote: >> >> Sets are values. If you add, remove, or mutate

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
> Am 16.10.2017 um 22:29 schrieb Adam Kemp : > > > >> On Oct 16, 2017, at 12:35 PM, Thorsten Seitz via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >> IMHO `elementsEqual` provides a nice example for a method which only makes >> sense on something meaningfully ordered: >>

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

2017-10-16 Thread Xiaodi Wu via swift-evolution
On Mon, Oct 16, 2017 at 14:21 Thorsten Seitz wrote: > Am 16.10.2017 um 16:20 schrieb Xiaodi Wu via swift-evolution < > swift-evolution@swift.org>: > > > On Mon, Oct 16, 2017 at 05:48 Jonathan Hull wrote: > >> >> On Oct 15, 2017, at 9:58 PM, Xiaodi Wu wrote: >> >> On Sun, Oct 15, 2017 at 8:51 PM

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

2017-10-16 Thread Adam Kemp via swift-evolution
> On Oct 16, 2017, at 3:08 PM, Thorsten Seitz 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 iteratio

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

2017-10-16 Thread Xiaodi Wu via swift-evolution
On Mon, Oct 16, 2017 at 15:31 Greg Parker wrote: > On Oct 16, 2017, at 1:08 PM, Xiaodi Wu via swift-evolution < > swift-evolution@swift.org> wrote: > > On Mon, Oct 16, 2017 at 13:15 David Sweeris wrote: > > >> On Oct 16, 2017, at 09:21, Michael Ilseman wrote: >> >> >> Sets are values. If you ad

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

2017-10-16 Thread Jonathan Hull via swift-evolution
> On Oct 16, 2017, at 1:05 PM, Xiaodi Wu wrote: > > > On Mon, Oct 16, 2017 at 10:49 Jonathan Hull > wrote: > >> On Oct 16, 2017, at 7:20 AM, Xiaodi Wu > > wrote: >> >> To start with, the one you gave as an example at the beginning of this >

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

2017-10-16 Thread Jonathan Hull via swift-evolution
To expand on this, Set([1,2,3,4,5]).hasPrefix([1,2,3]) currently returns true. But let’s say a year from now, we change Set to return an ordering based on hash values (which is entirely reasonable). Suddenly the same code may return true or false. No guarantees will be broken by doing that, b

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

2017-10-16 Thread Xiaodi Wu via swift-evolution
On Mon, Oct 16, 2017 at 6:10 PM, Jonathan Hull wrote: > > On Oct 16, 2017, at 1:05 PM, Xiaodi Wu wrote: > > > On Mon, Oct 16, 2017 at 10:49 Jonathan Hull wrote: > >> >> On Oct 16, 2017, at 7:20 AM, Xiaodi Wu wrote: >> >> To start with, the one you gave as an example at the beginning of this >>

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

2017-10-16 Thread Xiaodi Wu via swift-evolution
On Mon, Oct 16, 2017 at 6:40 PM, Jonathan Hull wrote: > To expand on this, Set([1,2,3,4,5]).hasPrefix([1,2,3]) currently returns > true. But let’s say a year from now, we change Set to return an ordering > based on hash values (which is entirely reasonable). Suddenly the same code > may return t

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

2017-10-16 Thread Howard Lovatt via swift-evolution
My preferences in order would be: 1. Split out of Sequence Iterable/ForEachable (whatever the name) and have Set and Dictionary conform to this new protocol instead of Sequence. With further protocols splits made to other 'mixin' protocols to keep the order of iteration undefined. 2. Rename e

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

2017-10-16 Thread David Sweeris via swift-evolution
> On Oct 16, 2017, at 1:07 PM, Xiaodi Wu wrote: > > > On Mon, Oct 16, 2017 at 13:15 David Sweeris > wrote: > > On Oct 16, 2017, at 09:21, Michael Ilseman > wrote: > >> >> >>> On Oct 16, 2017, at 8:46 AM, David Sweeris via swift-evolut

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

2017-10-16 Thread Xiaodi Wu via swift-evolution
On Mon, Oct 16, 2017 at 8:03 PM, David Sweeris wrote: > > On Oct 16, 2017, at 1:07 PM, Xiaodi Wu wrote: > > > On Mon, Oct 16, 2017 at 13:15 David Sweeris wrote: > >> >> On Oct 16, 2017, at 09:21, Michael Ilseman wrote: >> >> >> >> On Oct 16, 2017, at 8:46 AM, David Sweeris via swift-evolution

Re: [swift-evolution] /*Let it be*/ func() -> @discardable Bool {} /*Rather Than*/ @discardableResult func() -> Bool {}

2017-10-16 Thread Chris Lattner via swift-evolution
> On Oct 15, 2017, at 5:55 AM, Mike Kluev via swift-evolution > wrote: > > On 15 October 2017 at 13:35, Geordie Jay > wrote: > Also we're not talking about whether the Bool itself is discardable. For > example, it makes no sense to write: > > let something: discardab

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
> Am 17.10.2017 um 00:13 schrieb Xiaodi Wu : > > > On Mon, Oct 16, 2017 at 14:21 Thorsten Seitz wrote: >>> Am 16.10.2017 um 16:20 schrieb Xiaodi Wu via swift-evolution >>> : >>> >>> >>> On Mon, Oct 16, 2017 at 05:48 Jonathan Hull wrote: > On Oct 15, 2017, at 9:58 PM, Xiaodi Wu w

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
Even worse, Set([5,4,3,2,1]) will probably return false although it contains the same elements. -Thorsten > Am 17.10.2017 um 01:40 schrieb Jonathan Hull via swift-evolution > : > > To expand on this, Set([1,2,3,4,5]).hasPrefix([1,2,3]) currently returns > true. But let’s say a year from now

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
> Am 17.10.2017 um 01:43 schrieb Xiaodi Wu via swift-evolution > : > >> On Mon, Oct 16, 2017 at 6:10 PM, Jonathan Hull wrote: >> >>> On Oct 16, 2017, at 1:05 PM, Xiaodi Wu wrote: >>> >>> On Mon, Oct 16, 2017 at 10:49 Jonathan Hull wrote: >> On Oct 16, 2017, at 7:20 AM, Xiao

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
> Am 17.10.2017 um 00:15 schrieb Adam Kemp : > > >>> On Oct 16, 2017, at 3:08 PM, Thorsten Seitz 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. >> >> Her

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

2017-10-16 Thread Thorsten Seitz via swift-evolution
> Am 17.10.2017 um 03:20 schrieb Xiaodi Wu via swift-evolution > : > >> On Mon, Oct 16, 2017 at 8:03 PM, David Sweeris wrote: >> >>> On Oct 16, 2017, at 1:07 PM, Xiaodi Wu wrote: >>> >>> On Mon, Oct 16, 2017 at 13:15 David Sweeris wrote: > On Oct 16, 2017, at 09:21, Michael