[Development] commas in ctor-init-lists

Mathias Hasselmann mathias.hasselmann at kdab.com
Wed Jun 1 17:12:35 CEST 2016

First of all: Thank you Marc for raising that topic. Actually it also 
concerned me quite often, but so far I was to shy to mention this very 
opinionated topic.

Am 01.06.2016 um 15:44 schrieb Marc Mutz:
 > On Wednesday 01 June 2016 15:15:17 Sergio Martins wrote:
 >> On Wednesday, 1 June 2016 14:41:30 WEST Marc Mutz wrote:
 >>> Hi,
 >>> There seems to have been a silent underground move to uglify the Qt
 >>> sources , by using commas to introduce lines
 >>> . I have no idea where this came from

I've seen it first at Nokia, but it might be older. Reasoning was to 
minimize patches and to reduce chance of merge conflicts.

 >>> , but it looks butt

Which is highly subjective.

 >>> -ugly and it is in violation of http
 >>> (http://wiki.qt.io/Qt_Coding_Style#Line_breaks 2nd item: "Commas go at
 >>> the _end_ of wrapped lines")
 >> I think that refers to function calls and wasn't written with ctor
 >> init-lists in mind, but we can improve it so it stops being a violation.
 > I'm pretty sure it was written with ctor-init-lists in mind, because 
all of
 > QtBase uses trailing comma. I only come across the leading comma 
version in
 > new modules.
 >> Subjective reasons against leading commas:
 >> - It's ugly
 >> Subjective reasons against trailling commas:
 >> - It's ugly
 > I beg your pardon? Trailing commas are ugly? So where's the text 
editor that
 > folds prose text to have commas on the next line?

Now as we are at bike-sheding:

Yes, when it comes to initializer lists the trailing comma looks ugly to 
me. Because of the inconsistent two-space indent for the first 
initializer. Because line starts of are not aligned.

Lets proceed with smart-assing:

Trailing comma violates two very explicit rules:

- operators start at the beginning of the new lines
- 4 spaces are used for indentation

Leading comma:

- fixes those style violations
- reduces patch noise
- reduces inconsistent
- at the cost of maybe violating one rule with unclear scope ("commas go 
at the end of wrapped lines")

I for my part prefer leading comma.

 > Yes, and we should wait for / propose that they do the same change 
for ctor-
 > init-list, too. Not apply some horrible work-around.

By your choice of wording you seem rather upset. For myself I know that 
I feel upset when my comfort zone gets violate, when someone tries to 
changes things I grew comfortable with. How are the chances that you are 
upset just for the very same reason?

Mathias Hasselmann | mathias.hasselmann at kdab.com | Software Engineer
KDAB (Deutschland) GmbH&Co KG, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4016 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20160601/b33d655a/attachment.bin>

More information about the Development mailing list