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

Joe Groff jgroff at apple.com
Tue Jan 19 14:54:14 CST 2016


> On Jan 19, 2016, at 12:20 PM, Jacob Bandes-Storch <jtbandes at gmail.com> wrote:
> 
> Would you agree that it makes sense to:
> 
> 1. Automatically derive CaseEnumerable (or ValueEnumerable or whatever we choose) for Swift enums without associated values;

 I think you'd want to opt in, by declaring 'enum Foo: CaseEnumerable {}', since providing this conformance makes some implicit promises not every type may want to publicly commit to.

> 2. Still allow "extension Foo: CaseEnumerable {}" to add it to enums imported from (Obj-)C headers?
> 
> Or is it OK as-is, or is it worth pursuing some kind of "deriving" syntax?

This is just my opinion, but I think declaring a conformance ought to be enough. You could imagine the compiler-synthesized implementation being provided by a protocol extension with sufficiently advanced language features from the future to implement the default behavior.

-Joe


More information about the swift-evolution mailing list