[swift-evolution] [Proposal] Allow enumerating cases in enumerations

Leonardo Pessoa me at lmpessoa.com
Mon Jul 4 14:12:10 CDT 2016


And it is something the compiler can check whether it is necessary for
your code or not based on some simple and easy pattern. If it is so
simple, why not let the compiler handle it?

On 4 July 2016 at 16:02, Vladimir.S via swift-evolution
<swift-evolution at swift.org> wrote:
> On 04.07.2016 21:21, Brent Royal-Gordon via swift-evolution wrote:
>>>
>>> On Jul 4, 2016, at 10:43 AM, Leonardo Pessoa <me at lmpessoa.com> wrote:
>>>
>>> My issue with this being opt-in is third-party libraries.
>>
>>
>> That's why we have retroactive modeling. :^)
>>
>>         import SomeEnumKit
>>         extension SomeEnum: ValuesEnumerable {}
>>
>> You can extend another module's public enum to add conformance to a
>> protocol, and there's no reason it can't generate the code in your module
>> instead of theirs.
>>
>
> Yes, but I can't understand, why not give this ability to each enum? It
> seems like this feature is a very basic thing that enum must(IMO) to have.
> What kind of overhead this will generate? Static function or property that
> returns array as I understand should not generate any impact on memory
> required to store each separate *instance* of enum. I don't believe that
> adding a number of bytes to enum *type* to implement .allValues(or whatever
> named) will have any difference for total application/framework.
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list