[swift-evolution] [swift-evolution-announce] [Review] SE 0192 - Non-Exhaustive Enums

Sebastian Hagedorn sebastian at iosphere.de
Wed Dec 20 03:00:30 CST 2017


> What is your evaluation of the proposal?
> 
+1 if a `future` case (or similar solution… “unknown” might be a nice keyword, although some enums probably have an `.unknown` case which could be confusing) is added.
> Is the problem being addressed significant enough to warrant a change to Swift?
> 
I guess so – I understand this is a real issue for binary libraries (so basically, Apple).

I don’t think it’s an issue for open source libraries. Forcing the clients to update their code when they update the library (which they can do when they choose to, usually) seems reasonable to me, compared to the risk of not handling the new cases.
> Does this proposal fit well with the feel and direction of Swift?
> 
I don’t mind the default and I believe it’s ok to leave it to the library author to decide whether or not an enum should be exhaustive.

That said, I don’t think “you need to add a default case” feels very Swifty. It forces you to write code that you essentially have no idea about, so I would assume I’d just always put in an assert so I notice it in debug/beta builds, and keep my fingers crossed ignoring the unknown case doesn’t do any harm in release builds.

I strongly disagree with this:

>  The expectation is that switches over non-exhaustive enums are uncommon.


Basically every time I interact with an enum, I switch over it, to make sure I don’t forget anything, and to make sure I reconsider my code if the library changes. Since most SDK enums will become non-exhaustive, this is the 99% case for me.

Re: the future case: I don’t expect to actually put any code in there. If it’s code I intend to run in any case, it will typically be outside of the switch statement. Since the semantic of the new case is unknown to me, what code should I write to handle it? For that reason, I don’t think testability is a real issue here. I believe the limitation for single-value matching is fine for now, and could probably be extended to something like `case (true, future)`.
> If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> 
No.
> How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> 
Carefully read the proposal and followed some of the previous discussions.


> On 19. Dec 2017, at 23:58, Ted Kremenek <kremenek at apple.com> wrote:
> 
> The review of "SE 0192 - Non-Exhaustive Enums" begins now and runs through January 3, 2018.
> 
> The proposal is available here:
> 
> https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md <https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md>
> Reviews are an important part of the Swift evolution process. All review feedback should be sent to the swift-evolution mailing list at:
> 
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
> or, if you would like to keep your feedback private, directly to the review manager. 
> 
> When replying, please try to keep the proposal link at the top of the message:
> 
> Proposal link: https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md <https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md>
> ...
> Reply text
> ...
> Other replies
> What goes into a review of a proposal?
> 
> The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. 
> 
> When reviewing a proposal, here are some questions to consider:
> 
> What is your evaluation of the proposal?
> 
> Is the problem being addressed significant enough to warrant a change to Swift?
> 
> Does this proposal fit well with the feel and direction of Swift?
> 
> If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
> 
> How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> 
> Thanks,
> Ted Kremenek
> Review Manager
> _______________________________________________
> swift-evolution-announce mailing list
> swift-evolution-announce at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution-announce

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


More information about the swift-evolution mailing list