Re: [swift-evolution] Removing enumerated?

2017-02-17 Thread Ole Begemann via swift-evolution
> On 17 Feb 2017, at 16:53, Vladimir.S via swift-evolution > wrote: > > Btw, in context of discussion of indices, > should this be fixed soon: > > func function(c: C) { > for index in c.indices { >print(c[index]) > } > } > ERROR: cannot subscript a value of type 'C' with an index of type

Re: [swift-evolution] Removing enumerated?

2017-02-17 Thread Vladimir.S via swift-evolution
Btw, in context of discussion of indices, should this be fixed soon: func function(c: C) { for index in c.indices { print(c[index]) } } ERROR: cannot subscript a value of type 'C' with an index of type 'C.Indices.Iterator.Element' ? (have access for Swift 3.0.2 Release only for now, so

Re: [swift-evolution] Removing enumerated?

2017-02-06 Thread Dave Abrahams via swift-evolution
on Sun Feb 05 2017, Patrick Pijnappel wrote: > Note that zip(a.indices, a) requires advancing the index twice each > iteration, which for non-array collections is not necessarily super > trivial. Considering we're talking about such a low-level operation as > iterating through a collection this

Re: [swift-evolution] Removing enumerated?

2017-02-05 Thread Ben Cohen via swift-evolution
> On Feb 5, 2017, at 16:47, Patrick Pijnappel > wrote: > > Note that zip(a.indices, a) requires advancing the index twice each > iteration, which for non-array collections is not necessarily super trivial. > Considering we're talking about such a low-level operation as iterating > through a c

Re: [swift-evolution] Removing enumerated?

2017-02-05 Thread Patrick Pijnappel via swift-evolution
Note that zip(a.indices, a) requires advancing the index twice each iteration, which for non-array collections is not necessarily super trivial. Considering we're talking about such a low-level operation as iterating through a collection this might be worth considering. Personally I'm in favor of

Re: [swift-evolution] Removing enumerated?

2017-02-05 Thread Ben Cohen via swift-evolution
On Feb 5, 2017, at 08:12, Ben Cohen wrote: >> On Feb 4, 2017, at 14:43, Dave Abrahams via swift-evolution >> wrote: >> >> >> on Fri Feb 03 2017, Ben Cohen wrote: >> On Feb 3, 2017, at 3:27 PM, Dave Abrahams via swift-evolution wrote: I don't always make zip a method, b

Re: [swift-evolution] Removing enumerated?

2017-02-05 Thread Ben Cohen via swift-evolution
> On Feb 4, 2017, at 14:43, Dave Abrahams via swift-evolution > wrote: > > > on Fri Feb 03 2017, Ben Cohen wrote: > >>> On Feb 3, 2017, at 3:27 PM, Dave Abrahams via swift-evolution >>> wrote: >>> >>> I don't always make zip a method, but when I do, its argument label is >>> “to:” >> >> Hm

Re: [swift-evolution] Removing enumerated?

2017-02-04 Thread Dave Abrahams via swift-evolution
on Fri Feb 03 2017, Ben Cohen wrote: >> On Feb 3, 2017, at 3:27 PM, Dave Abrahams via swift-evolution >> wrote: >> >> I don't always make zip a method, but when I do, its argument label is >> “to:” > > Hmm, that doesn’t sound very natural to me. > > Then again the problem with “zip(with:)" is

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Shawn Erickson via swift-evolution
I use enumerated in many location in my code and have never expected it to be indexes but a counting of how many times I have looped. It says clearly what is does on the tin: "Returns a sequence of pairs (n, x), where n represents a consecutive integer starting at zero, and x represents an element

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Erica Sadun via swift-evolution
> On Feb 3, 2017, at 4:20 PM, Dave Abrahams wrote: > > > on Fri Feb 03 2017, Erica Sadun wrote: > >>> On Feb 3, 2017, at 2:58 PM, Ben Cohen wrote: >>> >>> On Feb 3, 2017, at 11:12 AM, Erica Sadun via swift-evolution > > wrote: >> I b

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Ben Cohen via swift-evolution
> On Feb 3, 2017, at 3:27 PM, Dave Abrahams via swift-evolution > wrote: > > I don't always make zip a method, but when I do, its argument label is > “to:” Hmm, that doesn’t sound very natural to me. Then again the problem with “zip(with:)" is it’s already kind of a term of art for a version

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Haravikk via swift-evolution
I'm in favour of getting rid of enumerated; I think like many people I used it expecting to get actual indices, and it's very easy to think this when working with arrays (as the values will in fact be perfectly valid). In reality the right way to do it is with one of the following: for eachInde

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Dave Abrahams via swift-evolution
on Fri Feb 03 2017, Ben Cohen wrote: >> On Feb 2, 2017, at 8:46 PM, Chris Lattner > wrote: >> >> It seems that you are leaning towards removing enumerated(). > > I’m actually kind of conflicted. > > Replacing enumerated() with indexed() feels replacing one problem for > another. Sometimes peo

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Dave Abrahams via swift-evolution
on Fri Feb 03 2017, Erica Sadun wrote: >> On Feb 3, 2017, at 2:58 PM, Ben Cohen wrote: >> >> >>> On Feb 3, 2017, at 11:12 AM, Erica Sadun via swift-evolution >>> > wrote: >>> > >>> I believe what people *want* is `indexed` over `enumerated`, and >>> consi

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Erica Sadun via swift-evolution
> On Feb 3, 2017, at 2:58 PM, Ben Cohen wrote: > > >> On Feb 3, 2017, at 11:12 AM, Erica Sadun via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >> I believe what people *want* is `indexed` over `enumerated`, and >> consistently for both array and array slices. >> > > I d

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Ben Cohen via swift-evolution
> On Feb 3, 2017, at 11:12 AM, Erica Sadun via swift-evolution > wrote: > > I believe what people *want* is `indexed` over `enumerated`, and consistently > for both array and array slices. > I don’t know if that’s true. Here’s an example (the only use of enumerated) from Alamofire: let acc

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Matthew Johnson via swift-evolution
> On Feb 3, 2017, at 3:41 PM, Ben Cohen via swift-evolution > wrote: > > >> On Feb 2, 2017, at 8:46 PM, Chris Lattner > > wrote: >> >> It seems that you are leaning towards removing enumerated(). > > I’m actually kind of conflicted. > > Replacing enumerated() wi

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Ben Cohen via swift-evolution
> On Feb 2, 2017, at 8:46 PM, Chris Lattner wrote: > > It seems that you are leaning towards removing enumerated(). I’m actually kind of conflicted. Replacing enumerated() with indexed() feels replacing one problem for another. Sometimes people want to number things, and might assume indexed

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Erica Sadun via swift-evolution
> On Feb 3, 2017, at 10:57 AM, Dave Abrahams via swift-evolution > wrote: > > > on Thu Feb 02 2017, Chris Lattner > wrote: > >> On Jan 31, 2017, at 11:16 AM, Ben Cohen via swift-evolution >> wrote: >>> >>> As we expand (and maybe contract :) the standard

Re: [swift-evolution] Removing enumerated?

2017-02-03 Thread Dave Abrahams via swift-evolution
on Thu Feb 02 2017, Chris Lattner wrote: > On Jan 31, 2017, at 11:16 AM, Ben Cohen via swift-evolution > wrote: >> >> As we expand (and maybe contract :) the standard library, this kind >> of question comes up a lot, so it is worth setting out some criteria >> for judging these “helper” metho

Re: [swift-evolution] Removing enumerated?

2017-02-02 Thread Erica Sadun via swift-evolution
> On Feb 2, 2017, at 9:46 PM, Chris Lattner via swift-evolution > wrote: > > On Jan 31, 2017, at 11:16 AM, Ben Cohen via swift-evolution > wrote: >> >> As we expand (and maybe contract :) the standard library, this kind of >> question comes up a lot, so it is worth setting out some criteria

Re: [swift-evolution] Removing enumerated?

2017-02-02 Thread Chris Lattner via swift-evolution
On Jan 31, 2017, at 11:16 AM, Ben Cohen via swift-evolution wrote: > > As we expand (and maybe contract :) the standard library, this kind of > question comes up a lot, so it is worth setting out some criteria for judging > these “helper” methods. Here’s my take on such a list (warning: object

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Jonathan Hull via swift-evolution
> On Jan 31, 2017, at 12:46 PM, Ben Cohen via swift-evolution > wrote: > >> // apply alternating view background colors >> for (i, view) in views.enumerated() { >> view.backgroundColor = i % 2 ? bgColor1 : bgColor2 >> } >> > > This is an interesting one because it highlights something els

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Jonathan Hull via swift-evolution
+1000 to all of this! > On Jan 31, 2017, at 11:16 AM, Ben Cohen via swift-evolution > wrote: > > I think whether enumerated() is justified as a method on Sequence is one > example of a wider question which definitely needs some discussion, which is: > where should the standard library draw th

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Xiaodi Wu via swift-evolution
On Tue, Jan 31, 2017 at 1:16 PM, Ben Cohen via swift-evolution < swift-evolution@swift.org> wrote: > I think whether enumerated() is justified as a method on Sequence is one > example of a wider question which definitely needs some discussion, which > is: where should the standard library draw the

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Matthew Johnson via swift-evolution
> On Jan 31, 2017, at 2:46 PM, Ben Cohen wrote: > >> >> On Jan 31, 2017, at 12:18 PM, Matthew Johnson > > wrote: >> >>> >>> On Jan 31, 2017, at 1:16 PM, Ben Cohen via swift-evolution >>> mailto:swift-evolution@swift.org>> wrote: >>> >>> I think whether enumera

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Ben Cohen via swift-evolution
> On Jan 31, 2017, at 12:18 PM, Matthew Johnson wrote: > >> >> On Jan 31, 2017, at 1:16 PM, Ben Cohen via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >> I think whether enumerated() is justified as a method on Sequence is one >> example of a wider question which definitel

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Matthew Johnson via swift-evolution
> On Jan 31, 2017, at 1:16 PM, Ben Cohen via swift-evolution > wrote: > > I think whether enumerated() is justified as a method on Sequence is one > example of a wider question which definitely needs some discussion, which is: > where should the standard library draw the line in providing con

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Ben Cohen via swift-evolution
I think whether enumerated() is justified as a method on Sequence is one example of a wider question which definitely needs some discussion, which is: where should the standard library draw the line in providing convenience functions that can easily be composed from other functions in the std li

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Jacob Bandes-Storch via swift-evolution
I'm still a fan of that indexed() proposal... On Tue, Jan 31, 2017 at 8:52 AM Matthew Johnson via swift-evolution < swift-evolution@swift.org> wrote: > On Jan 31, 2017, at 10:46 AM, Chris Eidhof wrote: > > I agree that it's very useful. I use it regularly. The documentation isn't > that unclear,

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Matthew Johnson via swift-evolution
> On Jan 31, 2017, at 10:46 AM, Chris Eidhof wrote: > > I agree that it's very useful. I use it regularly. The documentation isn't > that unclear, imo. To me, the underlying problem isn't enumerated. I think > the underlying cause is that collections aren't indexed with zero based > indices.i

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Chris Eidhof via swift-evolution
I agree that it's very useful. I use it regularly. The documentation isn't that unclear, imo. To me, the underlying problem isn't enumerated. I think the underlying cause is that collections aren't indexed with zero based indices.if you don't understand this (which is the case for many experienced

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Sean Heber via swift-evolution
In practical usage, I rarely use enumerated() - and almost every time I do use it, I end up refactoring 20 minutes later to not use it. Maybe that's just me, though. I imagine this isn’t helpful feedback. :P But perhaps we (or I) need to understand what it’s being used for or if there’s a differ

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Xiaodi Wu via swift-evolution
I totally sympathize with users being confused. It's an interesting idea to move it to Array only. The thing is, it does make sense (and wouldn't be confusing) to enumerate a dictionary or set. Moreover, the behavior is _exactly_ what it says on the tin: when you enumerate something in real life,

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Matthew Johnson via swift-evolution
> On Jan 31, 2017, at 10:36 AM, Xiaodi Wu via swift-evolution > wrote: > > I totally sympathize with users being confused. It's an interesting idea to > move it to Array only. > > The thing is, it does make sense (and wouldn't be confusing) to enumerate a > dictionary or set. Moreover, the b

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Ole Begemann via swift-evolution
On 31/01/2017 16:19, Ole Begemann via swift-evolution wrote: Here are three previous discussion about this topic: 1) December 2015: [Idea] Add an (Index,Element) sequence to CollectionType https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151221/004561.html and https://lists.sw

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Ole Begemann via swift-evolution
On 31/01/2017 15:24, Chris Eidhof via swift-evolution wrote: There are a couple of things that keep coming up, and a couple of mistakes that I see people making over and over again. One of them is that in almost every workshop, there's someone who thinks that `enumerated()` returns a list of (ind

Re: [swift-evolution] Removing enumerated?

2017-01-31 Thread Charlie Monroe via swift-evolution
> On Jan 31, 2017, at 3:24 PM, Chris Eidhof via swift-evolution > wrote: > > Hey everyone, > > I've organized a number of Swift workshops over the last two years. There are > a couple of things that keep coming up, and a couple of mistakes that I see > people making over and over again. One

[swift-evolution] Removing enumerated?

2017-01-31 Thread Chris Eidhof via swift-evolution
Hey everyone, I've organized a number of Swift workshops over the last two years. There are a couple of things that keep coming up, and a couple of mistakes that I see people making over and over again. One of them is that in almost every workshop, there's someone who thinks that `enumerated()` re