From kde-devel Mon Apr 29 20:31:33 2013 From: Olivier Goffart Date: Mon, 29 Apr 2013 20:31:33 +0000 To: kde-devel Subject: Re: [Development] kdelibs coding style Message-Id: <6235393.Vlibo0vl8M () gargamel> X-MARC-Message: https://marc.info/?l=kde-devel&m=136727142819267 On Monday 29 April 2013 09:43:55 Thiago Macieira wrote: > 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. I support the change to optionally permit the braces. -- Olivier Woboq - Qt services and support - http://woboq.com - http://code.woboq.org >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<