[swift-evolution] Warning when omitting default case for imported enums

Tino Heth 2th at gmx.de
Wed Feb 8 03:34:30 CST 2017


> Allowing the omission of a default case in an exhaustive switch makes the addition of a new case to the enum a breaking change. 
Depending on the context, even with a default the change might be breaking — but without giving notice to the framework client!
Additionally, it would feel very strange for me to have a default clause for bool-like enums* or other examples where there can't be any additional cases.

When there are two types of enums, the proposal makes sense for the "open"-ones; but I'm not sure if I like the concept of having two kinds of enum.

- Tino

* tiny anecdote: I actually have seen the equivalent of this

func reallyExhaustive(input: Bool) {
	if input == true {
		print("true")
	} else if input != true {
		print ("not true")
	} else {
		print("just to be save")
	}
}

in the wild… but I don't remember the comment I wrote ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170208/4d48ff67/attachment.html>


More information about the swift-evolution mailing list