[Development] commas in ctor-init-lists

Martin Smith Martin.Smith at qt.io
Fri Jun 3 08:28:19 CEST 2016


>but it is very structurally clean and in some circumstances I prefer it due to that.

The structure is a comma separated list. Historically, the comma has always been placed directly after the first of two list items. The comma tells the reader that another list item will follow. There is nothing to clean. Note the comma I used appeared right after the word "Historically,"  as did that one, and that one appeared right after the word "none."  The comma has never appeared as the first character of anything.

>Note there is a related coding style violation for if statements.

The relationship is tenuous. '||' is an operator, ',' is a separator. '||' represents a word to the reader ( "or"). The comma doesn't represent a word.

>This has the same benefits for diffs as the leading comma,

Is "diff noise" really a thing? If it is, why doesn't someone rewrite diff with an option to suppress it?
________________________________________
From: Development <development-bounces+martin.smith=qt.io at qt-project.org> on behalf of Allan Sandfeld Jensen <kde at carewolf.com>
Sent: Friday, June 3, 2016 2:02:55 AM
To: development at qt-project.org
Subject: Re: [Development] commas in ctor-init-lists

On Wednesday 01 June 2016, 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 am probably one of those introducing it since it comes from WebKit coding
style. Sorry, I also think it is kind of ugly, but it is very structurally
clean and in some circumstances I prefer it due to that.

Note there is a related coding style violation for if statements.

if (blabla
   || lala
   || justDoIt) {
   doIt();
}

This has the same benefits for diffs as the leading comma, though I mainly use
it to avoid the sub-expressions of the if statements to indent the same as
statements inside the if-block. This helps again make the code faster and
easier to read at glance, though it violates Qt coding style.

`Allan
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list