Re: [swift-evolution] [Proposal] Enum subsets

2016-06-07 Thread Chris Lattner via swift-evolution
On Jun 5, 2016, at 8:24 PM, T.J. Usiyan via swift-evolution wrote: > Sub typing is the answer that we're going with then? Most likely. At this point, we’re not really accepting additive changes to Swift 3 anyway, so any proposal would need to wait until post-swift 3

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-05 Thread T.J. Usiyan via swift-evolution
Sub typing is the answer that we're going with then? On Sat, Jun 4, 2016 at 4:26 PM, T.J. Usiyan wrote: > It could be a more general solution. I am unclear about what 'subtype > relationships' means here though. > > Are you talking a about what you allude to here? >

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-04 Thread T.J. Usiyan via swift-evolution
It could be a more general solution. I am unclear about what 'subtype relationships' means here though. Are you talking a about what you allude to here? https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151130/000525.html The benefit of explicitly narrowing, in my opinion, is that

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-04 Thread Chris Lattner via swift-evolution
> On Jun 3, 2016, at 10:34 PM, Austin Zheng wrote: > > It seems like it would make sense to model enum subsets as a subtype > relationship. > > Is the core team planning on drawing up a structs/enums subtyping proposal > later this year? I would *love* to get it in

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-04 Thread Matthew Johnson via swift-evolution
Sent from my iPad > On Jun 4, 2016, at 12:34 AM, Austin Zheng via swift-evolution > wrote: > > It seems like it would make sense to model enum subsets as a subtype > relationship. > > Is the core team planning on drawing up a structs/enums subtyping proposal >

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread Austin Zheng via swift-evolution
It seems like it would make sense to model enum subsets as a subtype relationship. Is the core team planning on drawing up a structs/enums subtyping proposal later this year? Austin > On Jun 3, 2016, at 10:25 PM, Chris Lattner wrote: > > >> On Jun 3, 2016, at 2:35 PM,

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread Chris Lattner via swift-evolution
> On Jun 3, 2016, at 2:35 PM, T.J. Usiyan via swift-evolution > wrote: > > Since this seems to have some interest, I've made a gist. > > https://gist.github.com/griotspeak/963bc87a0c244c120264b11fb022d78c >

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread Tony Allevato via swift-evolution
I like the idea, conceptually—having more set-like semantics for enums sounds like it would open up some interesting possibilities. (And I don't think we should limit ourselves to subsets either. Supersets are also interesting.) Things could get pretty tricky though, so there are a lot of gaps to

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread Christopher Kornher via swift-evolution
The syntax I described here has a number of problems, among them being: 1) Creating a supersets in the way described breaks down badly when the declarations exist within multiple modules. 2) The empty enum declaration is currently illegal and probably should be 3) The

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread Erica Sadun via swift-evolution
A few ideas: * Mention the pull request about member sets? * I'd try to give some more compelling use cases (Where a union type can be broadly applied across more specific uses, which then tend to narrow the applicable cases, and you want to limit (and compile check) those cases while

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread T.J. Usiyan via swift-evolution
Since this seems to have some interest, I've made a gist. https://gist.github.com/griotspeak/963bc87a0c244c120264b11fb022d78c Introduction This proposal adds/creates syntax to allow ad hoc creation of enums whose members are strict subsets of explicitly defined enums. Swift-evolution thread:

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread Austin Zheng via swift-evolution
I really like the idea behind this proposal. Some questions: - Would the enum 'slice' be a distinct type relative to the base enum? - On a related note, would shared cases between the sliced enum and the base enum be implicitly convertible? - If they aren't implicitly convertible between each

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread T.J. Usiyan via swift-evolution
My only hesitation with using `enum LCDColors : Colors` is that that syntax usually signals extending a type and I am not sure whether I am advocating for the ability to add something to `LCDColors` without adding it to `Colors`. I envisioned it as 'simply a subset of cases' but that is probably

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread Christopher Kornher via swift-evolution
Your original syntax makes LCDColors clearly a type. The typealias obscures the fact that a new type is being created. An alternative might be something like: ``` enum LCDColors : Colors { case red, green, blue } ``` or perhaps ``` enum LCDColors subset: Colors { case red,

Re: [swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread T.J. Usiyan via swift-evolution
I don't have a problem with something as explicit as that. I was mostly avoiding adding keywords with my proposed syntax. I have basically no tie to the proposed syntax. TJ On Fri, Jun 3, 2016 at 12:32 PM, Christopher Kornher wrote: > This could be useful in categorizing and

[swift-evolution] [Proposal] Enum subsets

2016-06-03 Thread T.J. Usiyan via swift-evolution
This is loosely related to but not meant to 'compete' with the ad hoc enum proposal. ## Introduction This proposal adds/creates syntax to allow ad hoc creation of enums whose members are strict subsets of explicitly defined enums. Swift-evolution thread: [Discussion thread topic for that