[swift-evolution] ValueEnumerable protocol with derived implementation for enums
Jacob Bandes-Storch
jtbandes at gmail.com
Sat Apr 23 01:48:59 CDT 2016
On Fri, Apr 22, 2016 at 11:34 PM, John McCall <rjmccall at apple.com> wrote:
> On Apr 22, 2016, at 11:11 PM, Jacob Bandes-Storch <jtbandes at gmail.com>
> wrote:
> On Fri, Apr 22, 2016 at 10:50 PM, John McCall <rjmccall at apple.com> wrote:
>
>>
>> I have not been following this discussion, but I would be extremely antsy
>> about guaranteeing any particular representation for the set of values.
>> Guaranteeing a contiguous array implementation seems like a really bad
>> idea, especially if that's taken to mean that we're going to actually
>> provide a static global array. But there's no way to avoid providing a
>> public API, because a public conformance itself implies a public API with
>> some level of corresponding overhead.
>>
>
> A "compiler magic" version of the feature, like #allValues(MyEnum), could
> generate a static array *internal* to the caller's module, but I'm sure
> there are implications or details of this which I'm not aware of.
>
>
> That cannot be reconciled with resilience. The caller cannot reliably
> know the set of stored cases; only the defining module can.
>
> For similar reasons, only the defining module can be allowed to magically
> derive a conformance to your protocol, if indeed it's done with a protocol.
>
What should/can this mean for enums imported from Obj-C, via other modules,
or bridging headers / custom module maps? In these cases, the defining
module has no Swift code. Is there a way to do it with pre-existing
metadata in the module?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160422/11f45350/attachment.html>
More information about the swift-evolution
mailing list