for loop parens

ixid nuaccount at gmail.com
Fri Jul 12 13:55:37 PDT 2013


> I'm not sure how much of a problem it is, especially given that 
> Go has a
> strict style guide, but the objection has come up that these 
> two are
> very different:
>
>   if i < f() {
>       g()
>   }
>
> and
>
>   if i < f()
>   {
>       g()
>   }
>
> In the second case, a semicolon is inserted on the same line as 
> the if.
>
> However, like I said, in idiomatic Go, this is simply not a 
> done thing.

Why would:

     if i < f()

gain a semi-colon? I thought the Go rules require that a line 
would compile to add the semi-colon. In D at least wouldn't the 
line have to be:

     if i < f() {}

before the compiler would add a semi-colon to it?


More information about the Digitalmars-d-learn mailing list