<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">"final"'s on my list of possible names! But it's not quite the same as 'final' for classes: "closed" only talks about what might change in the future, while 'final'-on-a-class also states something about the class in the present: it has no subclasses <i class="">now</i> as well as not gaining any new ones in the future. Still, it could be closed enough that it ends up being the best bet.</div><div class=""><br class=""></div><div class="">Jordan</div><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Aug 10, 2017, at 22:23, Rod Brown <<a href="mailto:rodney.brown6@icloud.com" class="">rodney.brown6@icloud.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Hi all,</div><div class=""><br class=""></div><div class="">I thought I’d chime in with my own 2c…</div><div class=""><br class=""></div><div class="">I’d probably prefer something more like “final” and vs non-final. It’s the concept we’re dancing around - can you add something to extend it?</div><div class=""><br class=""></div><div class="">In which case, final would allow exhaustive use, and non-final would require handling the default case. Currently all Swift API would convert as “final”, and all imported Obj-C API (with perhaps exceptions) would import as is and require a default handling case. This negates the open vs public issue. But it does also mean that it would become a manual issue inside the module to mark the API as final to allow exhaustive switches, unless we say “exhaustive switches allowed on internal/fileprivate/private types”.</div><div class=""><br class=""></div><div class="">Unsure how this plays into the web of things, though…</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Rod</div><div class=""><br class=""></div><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 11 Aug 2017, at 9:41 am, Jordan Rose via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline"><br class=""><blockquote type="cite" class=""><div class="">On Aug 10, 2017, at 13:00, David Hart <<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="auto" class=""><br class=""><div class=""><br class="">On 10 Aug 2017, at 19:19, Jordan Rose <<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Aug 9, 2017, at 22:46, David Hart <<a href="mailto:david@hartbit.com" class="">david@hartbit.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 10 Aug 2017, at 02:42, Jordan Rose <<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div class="">:-) As you've all noted, there are some conflicting concerns for the default:</div><div class=""><br class=""></div><div class="">- Source compatibility: the existing behavior for an unannotated enum is "closed".</div><div class="">- Intuition: if you show someone an enum without an explicit annotation, they'll probably expect they can switch over it. (I'm going to say this is why Zach calls it a "sensible default".)</div><div class="">- Consistency: switches on an enum in the same module can always be exhaustive, so having it be different across modules is a bit annoying. (But 'public' already acts like this.)</div><div class=""><br class=""></div><div class="">vs.</div><div class=""><br class=""></div><div class="">- Library evolution: the default should promise less, so that you have the opportunity to change it.</div><div class="">- Flexibility: you can emulate an exhaustive switch with a non-exhaustive switch using fatalError, but not the other way around.</div><div class=""><br class=""></div><div class="">All of this is why I suggested it be an explicit annotation in either direction, but Matthew brought up the "keyword soup" problem—if you have to write (say) "public finite enum" and "public infinite enum", but would never write "private finite enum" or "private infinite enum",<span class="Apple-converted-space"> </span><i class="">something</i> is redundant here. Still, I'm uncomfortable with the default case being the one that constrains library authors, so at<span class="Apple-converted-space"> </span><i class="">least</i> for binary frameworks (those compiled "with resilience") I would want that to be explicit. That brings us to one more concern: how different should binary frameworks be from source frameworks?</div></div></div></blockquote><div class=""><br class=""></div><div class="">In terms of intuition and consistency, I think we should really try to learn from the simplicity of public/open:</div><div class=""><br class=""></div><div class="">* When<span class="Apple-converted-space"> </span><b class="">internal</b>, classes are sub-classable by default for<span class="Apple-converted-space"> </span><b class="">convenience</b>, but can be closed with the<span class="Apple-converted-space"> </span><b class="">final</b><span class="Apple-converted-space"> </span>keyword</div><div class="">* When<span class="Apple-converted-space"> </span><b class="">public</b>, classes are closed to sub-classing for<span class="Apple-converted-space"> </span><b class="">safety</b>, but can be opened up with the<span class="Apple-converted-space"> </span><b class="">open</b><span class="Apple-converted-space"> </span>keyword (which implies public).</div><div class=""><br class=""></div><div class="">If we try to mirror this behaviour (the keywords are just suggestions, not important):</div><div class=""><br class=""></div><div class="">* When<span class="Apple-converted-space"> </span><b class="">internal</b>, enums are exhaustive by default for<span class="Apple-converted-space"> </span><b class="">convenience</b>, but can be opened-up with the<span class="Apple-converted-space"> </span><b class="">partial</b><span class="Apple-converted-space"> </span>keyword</div><div class="">* When<span class="Apple-converted-space"> </span><b class="">public,<span class="Apple-converted-space"> </span></b>enums are non-exhaustive by default for<span class="Apple-converted-space"> </span><b class="">safety</b>, but can be made exhaustive with the <b class="">exhaustive</b> keyword (which implies public).</div></div></div></div></blockquote><br class=""></div><div class="">This is not a correct understanding of the internal/public distinction for classes, though. From inside a module, a public-but-not-open class is still subclassable, and similarly a public-but-not-"closed" enum will still be exhaustively switched. You don't have to worry about your<span class="Apple-converted-space"> </span><i class="">own</i> module changing out from under you.</div></div></blockquote><div class=""><br class=""></div><div class="">Correct. Thanks for the clarification! But you still agree with the argument, right? Convenience for same module enums (exhaustive by default), safety for clients of the module (not-exhaustive when public from outside the module), with the option to be explicit?</div></div></div></blockquote><div class=""><br class=""></div><div class="">That's the "library evolution" criterion above, yes. But the behavior of enums inside the module doesn't need to affect what we do across modules.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class="">And what do you think of the idea of having the « exhaustiveness » modifier imply public, like open does?</div></div></div></blockquote><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I'm a little less sure about that. It does help with the keyword soup problem, but it's also not as obviously about access as "open" was, and "open" can also appear where other access modifiers can appear (on methods, properties, and subscripts).</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Jordan</div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>