Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-09 Thread Tony Allevato via swift-evolution
On Fri, Sep 8, 2017 at 5:14 PM Xiaodi Wu wrote: > On Fri, Sep 8, 2017 at 4:08 PM, Matthew Johnson via swift-evolution < > swift-evolution@swift.org> wrote: > >> >> On Sep 8, 2017, at 12:05 PM, Tony Allevato >> wrote: >> >> >> >> On Fri, Sep 8, 2017

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-09 Thread Tony Allevato via swift-evolution
On Sat, Sep 9, 2017 at 11:36 AM Matthew Johnson via swift-evolution < swift-evolution@swift.org> wrote: > > > Sent from my iPad > > On Sep 9, 2017, at 11:42 AM, gs. wrote: > > How does fragility play into this? Does this only work for fragile > (closed) and

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-09 Thread Christopher Kornher via swift-evolution
> On Sep 9, 2017, at 12:36 PM, Matthew Johnson via swift-evolution > wrote: > > > > Sent from my iPad > > On Sep 9, 2017, at 11:42 AM, gs. > wrote: > >> How does fragility play into this? Does this only work

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-09 Thread Matthew Johnson via swift-evolution
Sent from my iPad > On Sep 9, 2017, at 11:42 AM, gs. wrote: > > How does fragility play into this? Does this only work for fragile (closed) > and internal/private/fileprivate enums? That's a great question. I think it would have to have that limitation. Using

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-09 Thread Matthew Johnson via swift-evolution
Sent from my iPad > On Sep 9, 2017, at 7:33 AM, Brent Royal-Gordon wrote: > >> On Sep 8, 2017, at 5:14 PM, Xiaodi Wu via swift-evolution >> wrote: >> >> Here, people just want an array of all cases. Give them an array of all >> cases.

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-09 Thread Brent Royal-Gordon via swift-evolution
> On Sep 8, 2017, at 5:14 PM, Xiaodi Wu via swift-evolution > wrote: > > Here, people just want an array of all cases. Give them an array of all > cases. When it's not possible (i.e., in the case of cases with associated > values), don't do it. I agree it should

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Xiaodi Wu via swift-evolution
On Fri, Sep 8, 2017 at 4:08 PM, Matthew Johnson via swift-evolution < swift-evolution@swift.org> wrote: > > On Sep 8, 2017, at 12:05 PM, Tony Allevato > wrote: > > > > On Fri, Sep 8, 2017 at 9:44 AM Matthew Johnson > wrote: > >> On Sep 8, 2017,

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Matthew Johnson via swift-evolution
> On Sep 8, 2017, at 12:05 PM, Tony Allevato wrote: > > > > On Fri, Sep 8, 2017 at 9:44 AM Matthew Johnson > wrote: >> On Sep 8, 2017, at 11:32 AM, Tony Allevato >

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Logan Shire via swift-evolution
Hey folks! Thanks for all the great feedback and discussion. I really like Tony's suggestion of the opt-in ValueEnumerable protocol. However, I think Kevin is right that it should be a simple array. If we wanted to get fancy, we could implement a custom integer indexed collection that indexed

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Kevin Nattinger via swift-evolution
I've been waiting for this for years. Literally since Swift was announced. IMO it's one of several major gaps in the language. Some thoughts: - It should be a simple array. - By far the most simple solution, and the one I (and, I'd guess, others) would expect. - Every time I've

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Tony Allevato via swift-evolution
On Fri, Sep 8, 2017 at 9:44 AM Matthew Johnson wrote: > On Sep 8, 2017, at 11:32 AM, Tony Allevato > wrote: > > > > On Fri, Sep 8, 2017 at 8:35 AM Matthew Johnson > wrote: > >> On Sep 8, 2017, at 9:53 AM, Tony Allevato

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Matthew Johnson via swift-evolution
> On Sep 8, 2017, at 11:32 AM, Tony Allevato wrote: > > > > On Fri, Sep 8, 2017 at 8:35 AM Matthew Johnson > wrote: >> On Sep 8, 2017, at 9:53 AM, Tony Allevato via swift-evolution >>

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Tony Allevato via swift-evolution
On Fri, Sep 8, 2017 at 8:35 AM Matthew Johnson wrote: > On Sep 8, 2017, at 9:53 AM, Tony Allevato via swift-evolution < > swift-evolution@swift.org> wrote: > > Thanks for bringing this up, Logan! It's something I've been thinking > about a lot lately after a conversation

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Matthew Johnson via swift-evolution
> On Sep 8, 2017, at 9:53 AM, Tony Allevato via swift-evolution > wrote: > > Thanks for bringing this up, Logan! It's something I've been thinking about a > lot lately after a conversation with some colleagues outside of this > community. Some of my thoughts: > >

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Tony Allevato via swift-evolution
Thanks for bringing this up, Logan! It's something I've been thinking about a lot lately after a conversation with some colleagues outside of this community. Some of my thoughts: AFAIK, there are two major use cases here: (1) you need the whole collection of cases, like in your example, and (2)

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Jonathan Hull via swift-evolution
+1000 I once made a country code enum, and creating that array was simple, but took forever, and was prone to mistakes. Thanks, Jon > On Sep 8, 2017, at 2:56 AM, Logan Shire via swift-evolution > wrote: > > Googling ‘swift iterate over enum cases’ yields many

Re: [swift-evolution] [Pitch] Synthesized static enum property to iterate over cases

2017-09-08 Thread Vladimir.S via swift-evolution
On 08.09.2017 12:56, Logan Shire via swift-evolution wrote: Googling ‘swift iterate over enum cases’ yields many results of various levels of hackery. Obviously it’s trivial to write a computed property that returns an enum’s cases as an array, but maintaining that is prone to error. If you