On segunda-feira, 29 de abril de 2013 17.16.49, Sergio Martins wrote: > The thing is, I just discovered that the kdelibs style[1] has a little > difference from Qt, it uses braces for one-line if statements. > > This seems to be a documentation/policy only rule, as the kdelibs code is > full of if's without braces.
Remember that kdelibs isn't completely ported over to the kdelibs coding style. So you may be seeing code that simply needs to be fixed when it's next touched. The brace-on-one-line-if was adopted for KDE for a couple of good reasons: 1) when you add a second line, the if line does not need to be changed 2) conversely, if the if had a second line and you remove it, you don't need to change the if 3) you're less likely to make this mistake: if (condition); doThat(); The reason Qt requests that the braces not be added is a simple one: 1) it's uglier With that in mind, I would suggest we change *both* coding styles to optionally permit the braces, and strongly suggest it for more-complex conditionals. In particular, it should suggest you leave the braces if you've reduced the statements to one line. -- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel Open Source Technology Center PGP/GPG: 0x6EF45358; fingerprint: E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development