Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2018-01-11 Thread Brent Royal-Gordon via swift-evolution
> On Jan 10, 2018, at 12:15 AM, Martin Waitz wrote: > > Hello Brent, > >> Am 10.01.2018 um 06:15 schrieb Brent Royal-Gordon via swift-evolution >> : >> >> For what it's worth, I *might* introduce a follow-up proposal with >> conformances for Bool and Optional. Their straightforwardness and ut

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2018-01-10 Thread Martin Waitz via swift-evolution
Hello Brent, > Am 10.01.2018 um 06:15 schrieb Brent Royal-Gordon via swift-evolution > : > > For what it's worth, I *might* introduce a follow-up proposal with > conformances for Bool and Optional. Their straightforwardness and utility > make them very tempting. A conditional conformance for

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2018-01-09 Thread Brent Royal-Gordon via swift-evolution
> On Jan 8, 2018, at 11:02 AM, Robert Widmann via swift-evolution > wrote: > > As you note, integral types and Bool and some enums that fall outside the > scope of the synthesis requirements fit this mold quite nicely. We do not > include them in the proposal partially to keep things simple,

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2018-01-08 Thread Karl Wagner via swift-evolution
> On 7. Jan 2018, at 18:47, Robert Widmann wrote: > > > > ~Robert Widmann > > 2017/12/31 11:02、Karl Wagner via swift-evolution >のメール: > >> >> >>> On 31. Dec 2017, at 00:12, Jacob Bandes-Storch via swift-evolution >>> mailto:swift-evolution@swift.org>>

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2018-01-08 Thread Robert Widmann via swift-evolution
~Robert Widmann 2017/12/31 11:02、Karl Wagner via swift-evolution のメール: > > >> On 31. Dec 2017, at 00:12, Jacob Bandes-Storch via swift-evolution >> wrote: >> >> Sorry for the delay. I've just updated the proposal text to incorporate >> various changes, some contributed by others. >> >>

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-31 Thread Karl Wagner via swift-evolution
> On 31. Dec 2017, at 00:12, Jacob Bandes-Storch via swift-evolution > wrote: > > Sorry for the delay. I've just updated the proposal text to incorporate > various changes, some contributed by others. > > https://github.com/jtbandes/swift-evolution/blob/case-enumerable/proposals/-derived

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-31 Thread Félix Cloutier via swift-evolution
In addition to what Chris said: enums imported from C and @objc enums can both have extensions and conform to protocols, so IMO it should be legal to write something like `extension Foundation.ComparisonResult: ValueEnumerable {}`. Félix > Le 30 déc. 2017 à 19:00, Jacob Bandes-Storch via swift-

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-30 Thread Matthew Johnson via swift-evolution
This looks really nice. Thank you for doing the legwork of researching previous discussions and writing up a detailed proposal! The motivation discusses the common use case of using an enum in a data source implementation which requires 0-based Int indices. However, the proposed solution as-w

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-30 Thread Jacob Bandes-Storch via swift-evolution
Re-reading this thread and thinking about it more, I think I agree :) Updating again... On Sat, Dec 30, 2017 at 3:44 PM, Chris Lattner wrote: > On Dec 30, 2017, at 3:12 PM, Jacob Bandes-Storch via swift-evolution < > swift-evolution@swift.org> wrote: > > Sorry for the delay. I've just updated th

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-30 Thread Chris Lattner via swift-evolution
On Dec 30, 2017, at 3:12 PM, Jacob Bandes-Storch via swift-evolution wrote: > Sorry for the delay. I've just updated the proposal text to incorporate > various changes, some contributed by others. > > https://github.com/jtbandes/swift-evolution/blob/case-enumerable/proposals/-derived-collec

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-30 Thread Jacob Bandes-Storch via swift-evolution
Sorry for the delay. I've just updated the proposal text to incorporate various changes, some contributed by others. https://github.com/jtbandes/swift-evolution/blob/case-enumerable/proposals/-derived-collection-of-enum-cases.md Robert's implementation

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-09 Thread Step Christopher via swift-evolution
The “base” case desire makes sense to me, but not as a part of this proposal. It might be a good follow-on. If all associated values are enumerable, it is tempting to try to make the top level enum valueEnumerable too. I wonder if even that should be a follow-on feature. As far as source-ord

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-09 Thread Jonathan Hull via swift-evolution
> On Nov 14, 2017, at 9:06 PM, Brent Royal-Gordon via swift-dev > wrote: > >> On Nov 14, 2017, at 5:21 PM, Xiaodi Wu > > wrote: >> >> 1. It must be possible to easily access the count of values, and to access >> any particular value using contiguous `Int` indices.

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-09 Thread Karl Wagner via swift-evolution
Personally, I think this dovetails quite nicely with the ‘random’ discussion. Enums are just one kind of type with a finite set of values; Int and Bool also fit that description, as may many structs and even classes. Having a general way to express that would be quite nice, IMO. - Karl > On 9.

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-12-08 Thread Step Christopher via swift-evolution
Has this stalled out again? I would like to help with the proposal and even attempt implementation. I also need to catch up on the resilient discussion regarding enum case ordering. > On Nov 14, 2017, at 10:50 PM, Jacob Bandes-Storch via swift-evolution > wrote: > > > > Jacob Bandes-Stor

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-14 Thread Jacob Bandes-Storch via swift-evolution
Jacob Bandes-Storch On Tue, Nov 14, 2017 at 9:06 PM, Brent Royal-Gordon wrote: > On Nov 14, 2017, at 5:21 PM, Xiaodi Wu wrote: > > 1. It must be possible to easily access the count of values, and to access >> any particular value using contiguous `Int` indices. This could be achieved >> either

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-14 Thread Xiaodi Wu via swift-evolution
On Tue, Nov 14, 2017 at 11:06 PM, Brent Royal-Gordon wrote: > On Nov 14, 2017, at 5:21 PM, Xiaodi Wu wrote: > > 1. It must be possible to easily access the count of values, and to access >> any particular value using contiguous `Int` indices. This could be achieved >> either by directly accessin

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-14 Thread Brent Royal-Gordon via swift-evolution
> On Nov 14, 2017, at 5:21 PM, Xiaodi Wu wrote: > > 1. It must be possible to easily access the count of values, and to access > any particular value using contiguous `Int` indices. This could be achieved > either by directly accessing elements in the list of values through an Int > subscript,

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-14 Thread Xiaodi Wu via swift-evolution
On Tue, Nov 14, 2017 at 5:49 AM, Brent Royal-Gordon wrote: > On Nov 13, 2017, at 9:21 PM, Xiaodi Wu wrote: > > ...I should add, if full conformance to `Collection` is still too much to > ask, enabling "for `case` in Foo.self" by magic would itself address the > entirety of the proposal's use cas

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-14 Thread Brent Royal-Gordon via swift-evolution
> On Nov 13, 2017, at 9:21 PM, Xiaodi Wu wrote: > > ...I should add, if full conformance to `Collection` is still too much to > ask, enabling "for `case` in Foo.self" by magic would itself address the > entirety of the proposal's use case, adding no API surface area. No, Xiaodi. No, it would

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-13 Thread Xiaodi Wu via swift-evolution
On Mon, Nov 13, 2017 at 11:15 PM, Xiaodi Wu wrote: > On Mon, Nov 13, 2017 at 8:16 PM, Brent Royal-Gordon < > br...@architechies.com> wrote: > >> On Nov 12, 2017, at 10:16 AM, Xiaodi Wu wrote: >> >> On Sun, Nov 12, 2017 at 4:54 AM, Brent Royal-Gordon < >> br...@architechies.com> wrote: >> >>> On

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-13 Thread Xiaodi Wu via swift-evolution
On Mon, Nov 13, 2017 at 8:16 PM, Brent Royal-Gordon wrote: > On Nov 12, 2017, at 10:16 AM, Xiaodi Wu wrote: > > On Sun, Nov 12, 2017 at 4:54 AM, Brent Royal-Gordon < > br...@architechies.com> wrote: > >> On Nov 10, 2017, at 11:01 PM, Xiaodi Wu wrote: >> >> Nit: if you want to call it `ValueEnum

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-13 Thread Brent Royal-Gordon via swift-evolution
> On Nov 12, 2017, at 10:16 AM, Xiaodi Wu wrote: > > On Sun, Nov 12, 2017 at 4:54 AM, Brent Royal-Gordon > wrote: >> On Nov 10, 2017, at 11:01 PM, Xiaodi Wu > > wrote: >> >> Nit: if you want to call it `ValueEnumerable`, then this shoul

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-12 Thread Xiaodi Wu via swift-evolution
On Sun, Nov 12, 2017 at 1:37 PM, Tony Allevato wrote: > > > On Sat, Nov 11, 2017 at 1:53 PM Xiaodi Wu wrote: > >> On Sat, Nov 11, 2017 at 3:15 PM, Tony Allevato >> wrote: >> >>> >>> >>> On Sat, Nov 11, 2017 at 10:28 AM Xiaodi Wu wrote: >>> On Sat, Nov 11, 2017 at 11:23 AM, Tony Allevato <

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-12 Thread Tony Allevato via swift-evolution
On Sat, Nov 11, 2017 at 1:53 PM Xiaodi Wu wrote: > On Sat, Nov 11, 2017 at 3:15 PM, Tony Allevato > wrote: > >> >> >> On Sat, Nov 11, 2017 at 10:28 AM Xiaodi Wu wrote: >> >>> On Sat, Nov 11, 2017 at 11:23 AM, Tony Allevato >> > wrote: >>> On Fri, Nov 10, 2017 at 11:01 PM Xiaodi W

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-12 Thread Xiaodi Wu via swift-evolution
On Sun, Nov 12, 2017 at 4:54 AM, Brent Royal-Gordon wrote: > On Nov 10, 2017, at 11:01 PM, Xiaodi Wu wrote: > > Nit: if you want to call it `ValueEnumerable`, then this should be > `DefaultValueCollection`. > > > I used `DefaultCaseCollection` because, although the protocol can work > with any t

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-12 Thread Brent Royal-Gordon via swift-evolution
> On Nov 10, 2017, at 11:01 PM, Xiaodi Wu wrote: > > Nit: if you want to call it `ValueEnumerable`, then this should be > `DefaultValueCollection`. I used `DefaultCaseCollection` because, although the protocol can work with any type to return its values, this type can only work with enums and

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-11 Thread Xiaodi Wu via swift-evolution
On Sat, Nov 11, 2017 at 3:15 PM, Tony Allevato wrote: > > > On Sat, Nov 11, 2017 at 10:28 AM Xiaodi Wu wrote: > >> On Sat, Nov 11, 2017 at 11:23 AM, Tony Allevato >> wrote: >> >>> >>> >>> On Fri, Nov 10, 2017 at 11:01 PM Xiaodi Wu via swift-evolution < >>> swift-evolution@swift.org> wrote: >>>

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-11 Thread Tony Allevato via swift-evolution
On Sat, Nov 11, 2017 at 10:28 AM Xiaodi Wu wrote: > On Sat, Nov 11, 2017 at 11:23 AM, Tony Allevato > wrote: > >> >> >> On Fri, Nov 10, 2017 at 11:01 PM Xiaodi Wu via swift-evolution < >> swift-evolution@swift.org> wrote: >> >>> Nit: if you want to call it `ValueEnumerable`, then this should be

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-11 Thread Xiaodi Wu via swift-evolution
On Sat, Nov 11, 2017 at 11:23 AM, Tony Allevato wrote: > > > On Fri, Nov 10, 2017 at 11:01 PM Xiaodi Wu via swift-evolution < > swift-evolution@swift.org> wrote: > >> On Sat, Nov 11, 2017 at 12:15 AM, Brent Royal-Gordon via swift-evolution >> wrote: >> >>> > Personally I like the flexibility pro

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-11 Thread Tony Allevato via swift-evolution
On Fri, Nov 10, 2017 at 11:01 PM Xiaodi Wu via swift-evolution < swift-evolution@swift.org> wrote: > On Sat, Nov 11, 2017 at 12:15 AM, Brent Royal-Gordon via swift-evolution < > swift-evolution@swift.org> wrote: > >> > Personally I like the flexibility provided by the associatedtype, but I >> also

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-10 Thread Xiaodi Wu via swift-evolution
On Sat, Nov 11, 2017 at 12:15 AM, Brent Royal-Gordon via swift-evolution < swift-evolution@swift.org> wrote: > > Personally I like the flexibility provided by the associatedtype, but I > also recognize it won't be incredibly useful for enums — more so if we > wanted to provide e.g. UInt8.allValues

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-10 Thread Brent Royal-Gordon via swift-evolution
> Personally I like the flexibility provided by the associatedtype, but I also > recognize it won't be incredibly useful for enums — more so if we wanted to > provide e.g. UInt8.allValues, whose ideal implementation might be "return > 0...UInt8.max". So I could see allowing allValues to be any s

Re: [swift-evolution] [swift-dev] Re-pitch: Deriving collections of enum cases

2017-11-10 Thread Robert Widmann via swift-evolution
> On Nov 6, 2017, at 2:54 AM, Jacob Bandes-Storch via swift-dev > wrote: > > Over a year ago, we discussed adding a magic "allValues"/"allCases" static > property on enums with a compiler-derived implementation. The original > proposal PR ha