[swift-evolution] Proposal: Make braces optional much like semicolons.

Charles Constant charles at charlesism.com
Sun Dec 20 12:47:09 CST 2015


I'm quite sure if Chris had announced "significant whitespace" instead of
"braces", the other half of the audience would have cheered :)

On Sun, Dec 20, 2015 at 9:05 AM, Amir Michail via swift-evolution <
swift-evolution at swift.org> wrote:

>
> > On Dec 20, 2015, at 11:44 AM, Bart Whiteley via swift-evolution <
> swift-evolution at swift.org> wrote:
> >
> > On Sun, Dec 20, 2015 at 8:17 AM, Amir Michail via swift-evolution
> > <swift-evolution at swift.org> wrote:
> >> // braces are optional here but you could still put them in if you want
> to
> >> for i in 0..<10
> >>    for j in 0..<5
> >>        if i % 2 == 0
> >>            print(i+j)
> >>        print(i*j)
> >>
> >
> > -1. Please no. The fact that Swift requires curly braces even in
> > situations where C does not is a great feature. I still remember the
> > cheer that erupted from the '14 WWDC crowd when mandatory braces were
> > announced -- and rightfully so. Many bugs are prevented by mandatory
> > braces.
>
> The reason they cheered is because omitting braces for one line scopes is
> a source of bugs. Braces should ALWAYS be required for one line scopes,
> even if indentation allows you to omit braces in other contexts.
>
>
>
> > _______________________________________________
> > swift-evolution mailing list
> > swift-evolution at swift.org
> > https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> 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/20151220/f34fad53/attachment.html>


More information about the swift-evolution mailing list