[swift-evolution] [Idea] Wrap switch cases in curly braces

G B g.c.b.at.work at gmail.com
Tue Jul 19 19:01:01 CDT 2016


The main advantage is not in this change by itself, but in the fact that it tidies up the syntax and makes it easier to support other additive proposals in the future that might make better use of the colon syntax— such as targeted continue statements in `switch` or a `switch` expression syntax.  Both could probably be accomplished without this change, but I think they’d be less clean.

I guess my argument on familiarity has been that using curly braces is more like the C family of languages in that the Swift `case`s are separate scopes and C/C++ would require curly braces to create those scopes. At the same time the Swift `switch` is different from the C `switch` in that it does not implicitly fall through so a small syntax difference isn’t without justification.


That said, reactions haven't been overwhelmingly positive, so I’ll let it go unless someone suggests otherwise.


> On Jul 18, 2016, at 16:23 , Chris Lattner <clattner at apple.com> wrote:
> 
> On Jul 17, 2016, at 10:07 PM, Jose Cheyo Jimenez via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> I think this proposal is not 
>> 
>>  ""better enough" for it to make sense to diverge from the precedent established by the C family of languages.”
>> 
>> And I think the same would go for this
>> 
>> “Swift is designed to feel like a member of the C family of languages. Switching keywords away from C precedent without strong motivation is a non-goal”
>> 
>> https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md <https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md>
>> 
>> I just don’t think we gain much by switching to curly braces. 
> 
> I agree.  I don’t think this proposal is worth considering at this point.
> 
> -Chris
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160719/11975d8d/attachment.html>


More information about the swift-evolution mailing list