[swift-evolution] [Idea] Wrap switch cases in curly braces
Jaden Geller
jaden.geller at gmail.com
Tue Jul 19 19:05:56 CDT 2016
It’s probably worth pointing out that Swift's `switch` statement has been a thing I’ve seen new programmers struggle with when learning Swift. The syntax differs quite significantly from other control flow constructs in the language.
> On Jul 19, 2016, at 5:04 PM, Jaden Geller <jaden.geller at gmail.com> wrote:
>
> I also agree that curly braces would be both *more* clear and *more* C-like for what it’s worth, but it seems like there may be no time for this. 😞
>
>> On Jul 19, 2016, at 5:01 PM, G B via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>
>> 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 <mailto: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
>>>
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160719/84167a33/attachment.html>
More information about the swift-evolution
mailing list