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

Jacob Bandes-Storch jtbandes at gmail.com
Wed Jan 20 23:25:55 CST 2016


Proposal revised & submitted:

https://github.com/apple/swift-evolution/pull/114

Jacob

On Wed, Jan 20, 2016 at 3:28 PM, <davesweeris at mac.com> wrote:

> Oh, ok. I must’ve misread something then.
>
> - Dave Sweeris
>
> > On Jan 20, 2016, at 15:25, Joe Groff <jgroff at apple.com> wrote:
> >
> >
> >> 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
> >>
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160120/11b52517/attachment.html>


More information about the swift-evolution mailing list