<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Dec 19, 2017, at 2:58 PM, Ted Kremenek via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><p style="-webkit-print-color-adjust: exact; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255); margin-top: 0px !important;" class="">The review of "SE 0192 - Non-Exhaustive Enums" begins now and runs through&nbsp;<strong style="-webkit-print-color-adjust: exact;" class="">January 3, 2018</strong>.</p><p style="-webkit-print-color-adjust: exact; margin: 15px 0px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class="">The proposal is available here:</p><blockquote style="-webkit-print-color-adjust: exact; margin: 15px 0px; border-left-width: 4px; border-left-style: solid; border-left-color: rgb(221, 221, 221); padding: 0px 15px; color: rgb(119, 119, 119); font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><div style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md</a></div></blockquote><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">What is your evaluation of the proposal?</p></li></ul></div></div></blockquote><div>I was going to say -100 without future, +1 with, but other arguments on this thread have put me on the fence to mildly against, so -100 without future, -ε with.</div><div><br class=""></div><div><br class=""></div><div>In the proposal, there is the following text:</div><div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; font-variant-ligatures: normal; orphans: 2; widows: 2;" class=""></p></div><blockquote type="cite" class=""><div><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 13px; font-variant-ligatures: normal; orphans: 2; widows: 2;" class="">The consequences of losing exhaustiveness checking for non-exhaustive enums are discussed in the "Alternatives considered" section at the end of this proposal.</p><blockquote style="box-sizing: border-box; margin: 0px 0px 16px; padding: 0px 1em; color: rgb(106, 115, 125); border-left-width: 0.25em; border-left-style: solid; border-left-color: rgb(223, 226, 229); font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 13px; font-variant-ligatures: normal; orphans: 2; widows: 2;" class=""><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;" class="">A number of pre-reviewers have been concerned about the loss of exhaustiveness checking and the subsequent difficulty in updating to a new version of a dependency. In the original swift-evolution thread, Vladimir S.&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171002/040053.html" rel="nofollow" style="box-sizing: border-box; color: rgb(3, 102, 214); outline-width: 0px;" class="">describes the concerning scenario</a>&nbsp;in detail.</div></blockquote></div></blockquote><div>I find it deeply disturbing that this scenario is acknowledged as "concerning" and yet ignored without justification in the proposal proper, and in the "alternatives" dismissed solely based on a baseless assumption—that the situation will be "uncommon." Even if it were an uncommon case, the negative impact is still dire enough and without a good workaround that I'd argue strongly that the concern be addressed properly.</div><div><br class=""></div><div>The justification put forward to reject a `future` case is that "The expectation is that switches over non-exhaustive enums are uncommon." However, there is no evidence to support that assertion, and there are a huge number of enums in even just Apple's frameworks that people reasonably can, and in some cases really should, switch over. Go through any of the iOS frameworks and find authorization enums and delegates with enums in a callback, and you're likely to find some that it makes sense for a client to switch over. Just a few off the top of my head that I have personally switched on:</div><div><br class=""></div><div>CoreBluetooth</div><div>- CBManagerState</div><div>- CBPeripheralManagerAuthorizationStatus</div><div>- CBPeripheralState</div><div>CoreLocation</div><div>- CLAuthorizationStatus</div><div>- CLActivityType</div><div>CoreData</div><div>- NSFetchedResultsChangeType</div><div>MessageUI</div><div>- MessageComposeResult</div><div>UIKit</div><div>- UITableViewCellEditingStyle</div><div><br class=""></div><div>Every framework that requires user permission has its own authorization enum, many have an additional state enum, and for most delegate callbacks with an enum argument it's often a good idea to switch over the cases.</div><br class=""><div>As a real-life example above and beyond the one referenced above, In the fairly small codebase I'm working in at the moment, I count a bit over 12klocs, 80-ish switches, and 6 switches that would need a `future` case (non-exhaustive, from Apple frameworks). That's about one per 2klocs, It probably wouldn't scale linearly in larger projects, but just their prevalence in the apple frameworks as I pointed out above would suggest it does grow significantly.</div><div><br class=""></div>The extra onus on project authors required by not including a future case for those cases would make upgrading libraries and iOS versions incredibly difficult and error-prone. To ensure correctness, you would have to go over every single switch in your app, figure out the type it's switching on, and if the type is external and nonexhaustive, check that there are no new cases. Even if this is "not expected to be the common case," omitting the `future` means you have to either keep track of where all your relevant switch statements are and check them on every upgrade, go through and evaluate every switch statement to figure out whether you need to check for extra cases, or go through the API diff, find any added enum cases, and find every switch in your codebase that switches on them. All three options are dangerously error-prone and unacceptable.</div><div><br class=""></div><div>In summary, failing to include a future case but requiring default instead would place an unacceptable burden on every nontrivial project every time a library is upgraded and (and I don't say this lightly) would almost certainly be the biggest mistake the Swift community has ever made.</div><div><br class=""></div><div>There is an existing implementation along with the PR, so has anyone tried this change a project of significant size that uses a variety of Apple frameworks? How many `default`s did you have to put in that should be `future`, and how would you feel about having to find all those places again and any more that may be put in in a year or two *without* compiler checking?</div><div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">Is the problem being addressed significant enough to warrant a change to Swift?</p></li></ul></div></div></blockquote>The problem needs to be addressed, certainly.<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">Does this proposal fit well with the feel and direction of Swift?</p></li></ul></div></div></blockquote>With future, sure. Without, absolutely not. As demonstrated and even acknowledged but dismissed without justification, it introduces an enormous issue with compile-time safety.<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?</p></li></ul></div></div></blockquote>N/a<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">How much effort did you put into your review? A glance, a quick reading, or an in-depth study?</p></li></ul></div></div></blockquote>I kept maybe half an eye on the original thread, but read the proposal and other posts in this review thread thoroughly.<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><p style="-webkit-print-color-adjust: exact; margin-top: 15px; margin-right: 0px; margin-left: 0px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255); margin-bottom: 0px !important;" class="">Thanks,<br style="-webkit-print-color-adjust: exact;" class="">Ted Kremenek<br style="-webkit-print-color-adjust: exact;" class="">Review Manager</p></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>