[swift-evolution] Handling unknown cases in enums [RE: SE-0192]

Goffredo Marocchi panajev at gmail.com
Wed Jan 10 23:32:52 CST 2018


I am sorry, but I have to disagree here. Having two separate proposals would make it highly more likely that one thing is done and the other one postponed and postponed until it seems no longer relevant in the grand scheme of things... first we lost labels in callbacks / stores functions (has there been at least some Core Team chat about this after last year?) and now we are losing compiler enforced exhaustive switching over enum... not only that, until we improve diagnostic and at least warn users we are now even behind Objective-C as compiler can enforce exhaustive switching and actually mandate no default case for enums through a compiler warning.

Sent from my iPhone

> On 11 Jan 2018, at 04:31, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Jan 10, 2018, at 10:10 AM, Jordan Rose <jordan_rose at apple.com> wrote:
>> 
>>>> 
>>>> - Matching known cases is a feature, not a limitation, to avoid existing code changing meaning when you recompile. I'll admit that's not the strongest motivation, though, since other things can change the meaning of existing code when you recompile already.
>>> 
>>> I’m not sure I understand this. 
>>> 
>>> The whole motivation for this feature is to notify people if they are not handling a “newly known” case.  If they don’t care about this, they can just use default.
>> 
>> Notify, yes. Error, no. It's a design goal that adding a new case does not break source compatibility in addition to not breaking binary compatibility (because people don't like editing their dependencies) and therefore the behavior has to be defined when they recompile with no changes.
>> 
> 
> Ok, if that’s the desired design, then (IMO) the right way to spell it is “unknown default:” and it should have semantics basically aligned with the design you laid out in the revision of the proposal.  If this is supposed to be an error, then it should be a pattern production.
> 
> Do you have a sense for whether this is what people want?  We really should have a review cycle evaluating exactly this sort of tradeoff.
> 
> In any case, I’ve said this before off-list, but I find this whole discussion (of how to improve diagnostics for unknown cases) to be separable from the core issue required to get to ABI stability.  It seems to me that we could split this (ongoing) design discussion off into a separate SE, allowing you to get on with the relatively uncontroversial and critical parts in SE-0192.
> 
> -Chris
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20180111/8d180e37/attachment.html>


More information about the swift-evolution mailing list