[swift-evolution] Pre-proposal: CaseEnumerable protocol (derived collection of enum cases)

Joe Groff jgroff at apple.com
Wed Jan 20 17:25:53 CST 2016


> On Jan 20, 2016, at 3:24 PM, davesweeris at mac.com wrote:
> 
> Off the top of my head?
> enum NumClassification {
> 	case None(Int)
> 	case Even(Int)
> 	case Odd(Int)
> 	case Prime(Int)
> 	case Negative(Int)
> 	case Positive(Int) //Always gotta end on a positive note :-)
> }
> 
> Although I must admit, if there’s a purpose to CaseEnumerable (or whatever it’s being called now) beyond just automatically getting a static cases:[Self] and labels:[String], I’ve missed the memo about it.

That's the extent of it, as I see it. Asking for the collection of case constructors seems like a different thing to me—you're getting a [(Payload) -> Self] rather than a [Self] collection.

-Joe

> 
> - Dave Sweeris
> 
>> On Jan 20, 2016, at 15:18, Joe Groff <jgroff at apple.com> wrote:
>> 
>> 
>>> On Jan 20, 2016, at 3:13 PM, David Sweeris <davesweeris at mac.com> wrote:
>>> 
>>> If the associated values are all enums themselves, that's great. What if your enum is an error type, and the associated values are all strings with maybe diagnostic info or time stamps or something?
>> 
>> Then I don't even know what you would use CaseEnumerable for. Do you have a more concrete use case in mind?
>> 
>> -Joe
> 



More information about the swift-evolution mailing list