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

Chris Lattner clattner at nondot.org
Wed Jan 10 22:30:49 CST 2018


> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20180110/b39f9ec8/attachment.html>


More information about the swift-evolution mailing list