I agree with Stephen Celis that the best names for this (yet) are definitely 
`cases` and optionally `rawValues` if the cases are RawRepresentable.

Regarding handling cases with associated values where some of those values are 
other enums, it seems odd to me to try to return every variation of each case. 
I can’t picture how that would work sanely when there are multiple associated 
values, such as a case like `MyCase(String, SomeEnum)`. Therefore I prefer the 
idea of having the array contain the constructor for cases with associated 
values. The main problem I see here is that the type system (as far as I know) 
can’t fully represent that type of thing, but I think it’s still potentially 
valuable. Related to this I’m putting together a separate proposal that 
explores a bit more on why I believe the enum constructor to be valuable, 
though that’s in a bit of a different context.

I shared these thoughts in a bit more detail here a couple weeks ago, with some 
followup in the next two messages:

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001864.html

Zef



> On Dec 21, 2015, at 3:58 PM, Erica Sadun via swift-evolution 
> <[email protected]> wrote:
> 
> That would be okay too. Thank you, Santa Joe.
> 
> -- E, who hopes she was on the nice list.
> 
>> On Dec 21, 2015, at 3:56 PM, Joe Groff <[email protected]> wrote:
>> 
>> 
>>> On Dec 21, 2015, at 12:24 PM, Erica Sadun <[email protected]> wrote:
>>> 
>>> I could be satisfied by such an approach.  I could even be more satisfied if
>>> 
>>>> enum Foo: ValueEnumerable { case A, B, C }
>>> 
>>> 
>>> were also essentially an alias for
>>> 
>>>> enum Foo: Int, ValueEnumerable { case A=0, B, C }
>>> 
>>> :)
>> 
>> If the value collection were sufficiently capable, you wouldn't necessarily 
>> need an implicit Int raw value; you could do `allValues.indexOf(.A)` to get 
>> the index for a case.
>> 
>> -Joe
>> 
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to