[swift-evolution] Proposal: Make braces optional much like semicolons.
Amir Michail
a.michail at me.com
Sun Dec 20 09:54:44 CST 2015
> On Dec 20, 2015, at 10:19 AM, Stephen Celis <stephen.celis at gmail.com> wrote:
>
> There was a thread for this posted yesterday:
>
> https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003631.html
>
Much of that discussion doesn’t consider the possibility of making braces OPTIONAL as shown in the examples.
> 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