[swift-evolution] About "default" keyword in switch statement
jeremy.j.pereira at googlemail.com
Tue Dec 6 11:51:47 CST 2016
> On 6 Dec 2016, at 04:11, 星野恵瑠 via swift-evolution <swift-evolution at swift.org> wrote:
> I've read this mail and totally understand that Swift is designed to be familiar with C family languages, which "default" is widely used.
Did you read the first paragraph of that page and follow its advice to "familiarize yourself with the discussions that we have already had”? They were heated and protracted and ended with the situation unchanged.
Personally, I don’t see the problem with default. I really don’t think the breakage of pretty much everything caused by removing it is worth it even if there are better synonyms.
Plus, I little while ago, I came across a situation where the code would have read marginally better if I had been able to put the default case at the top of the switch (illegal in Swift 3) with the other cases below it (illegal in Swift 3). If that restriction were ever to be lifted, “else” would suddenly be a very poor choice.
> But since Swift 3.0 has already make many source breaking changes and supports many features which most C family languages don't have, like labels in functions (except Objective-C, I guess), "inout" keyword in functions, etc, and one of Swift's goals is to make syntax "clear," hope we can re-consider the "default" keyword.
> Thanks for your time.
>> 2016/12/06 12:48、星野恵瑠 <el.hoshino at me.com> のメール：
>> Many languages have a switch statement and most (maybe all?) of them use "default" keyword for the condition which doesn't match any of those listed in the switch statement.
>> But sometimes that condition is just an exception, which literally IS NOT a default condition.
>> So how about using other keywords like "else" instead of "default"?
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution