> On Dec 20, 2015, at 12:55 PM, Patrick Gili <[email protected]> 
> wrote:
> 
> I would not like to see braces made optional. First, I think this reduces the 
> readability of the code. While readability might be somewhat subjective, 
> compare these two blocks of code:
> 
> // With braces             // Without braces
> for i in 0..<10 {          for i in 0..<10
>     for j in 0..<5 {           for j in 0..<5
>         if i %2 == 0 {             if i %2 == 0
>             print(i+j)                  print(i+j)
>         }                          print(i*j)
>         print(i*j)
>     }
> }
> 
> IMHO, it is easier to see that "print(i*j) is part of the block belonging to 
> the inner for loop, rather than the if statement, when braces are present.
> 
> Second, this is Python's style, which comes at a cost: the grammar is not 
> context free. While this type of grammar is safer, especially for programmers 
> with little to no experience, the imposition on veteran programmers is 
> constraining.
> 
> I realize that you're proposing that this be optional. However, this would 
> introduce a new problem. Now you have two distinctly different styles of code 
> out there. IMHO, this further increases the readability issue.

Swift already supports different programming paradigms (e.g., functional, OOP, 
etc.) which is a much bigger deal than the optional brace issue.

> 
> Cheers,
> -Patrick
> 
>> On Dec 20, 2015, at 10:17 AM, Amir Michail via swift-evolution 
>> <[email protected] <mailto:[email protected]>> 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
>> [email protected] <mailto:[email protected]>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to