[swift-evolution] Enums and Source Compatibility
Rex Fenley
rex at remind101.com
Fri Sep 15 17:47:02 CDT 2017
Hey Jordan,
Thank you for the time writing this up. I've been following along to the
discussion somewhat closely and have kept silent because `exhaustive` was
originally set to be the default for enums. However, that changed and so
I'd like to voice my opinion, I frankly don't like this idea.
At remind we use algebraic data types religiously for managing state and
data and rely on exhaustive pattern matching to guarantee we're handling
all states in our code. We're splitting out our code across modules and
having this guarantee has been a joy to work with.
The benefit of making nonexhaustive the default for Swift 5 across all
multi-module code (besides C code) seems minimal to me. If a developer
feels like they're unnecessarily managing enum cases, they can simply add a
`default` case whenever they please. This is already the case and I'm
curious if there's every been any complaints about this and what they would
be. I'd prefer to be cautious and force exhaustive pattern matching in all
possible cases and leave it up to the developer to choose not to.
Ideally in my mind, these keywords won't be necessary. All Swift enums will
remain as they are, exhaustively pattern matched by default. Enums from C
code will be explicitly nonexhaustive in all cases.
--
Rex Fenley | IOS DEVELOPER
Remind.com <https://www.remind.com/> | BLOG <http://blog.remind.com/>
| FOLLOW
US <https://twitter.com/remindhq> | LIKE US
<https://www.facebook.com/remindhq>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170915/187a1a59/attachment.html>
More information about the swift-evolution
mailing list