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

Stephen Celis stephen.celis at gmail.com
Sun Dec 20 09:19:21 CST 2015


There was a thread for this posted yesterday:

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003631.html

Stephen

> On Dec 20, 2015, at 10: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)
> 
> // braces are necessary because “print" is on the same line as ”if"
> for i in 0..<10
>    for j in 0..<5
>        if i % 2 == 0 { print(i+j) }
>        print(i*j)
> 
> // braces are necessary with incorrect/unconventional indentation
>    for i in 0..<10 {
> for j in 0..<5 {
> if i % 2 == 0 {
> print(i+j)
> }
> print(i*j)
> }
> }
> 
> As for the space vs tab issue, my preference would be to allow only spaces to make braces optional. An alternative would be to use the python 3 indentation rules with respect to spaces and tabs.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list