> On Jun 3, 2016, at 10:07 AM, Martin Smith <martin.sm...@qt.io> wrote:
> 
> I think it would be instructive to hear the reasoning of the first engineer 
> to add a ctor-init-list on separate lines with leading commas. I have been in 
> the software engineering business since BEFORE Al Gore invented the internet, 
> yet I have never been temped to start a line with a comma.

> What devious thinking would cause one to do that in the first place?

Why devious?

Let’s have a look at the advantages of both styles:

comma at the end:

* feels more natural wrt natural languages

comma at the start:

* better visual alignment together with the : and , all at the start
* easier diff when adding something at the end (which is commonly done)
* easier rearrangement when it involves the last item
* easier ifdef’ing of individual items

The advantages of the one are the disadvantages of the other.

So some people argue that “feels more natural” overweighs the perceived small 
advantages of comma at the start.
And some other people argue that coding has not much to do with natural 
languages anyhow, the “small” advantages are worth the change, and it doesn’t 
feel unnatural anymore after getting used to it.

> Then why not just add a note to the Qt coding style saying that using the 
> leading comma is allowed|recommended when using conditional compilation in a 
> comma list? Why does it have to be uniform throughout the entire code base? 
> Sometimes diffs are hard to read.

Possibly because for some people consistency is of higher value.

(Disclaimer: I personally really don’t care which style is taken.)

Br, Eike

> martin
> 
> ________________________________________
> From: Development <development-bounces+martin.smith=qt...@qt-project.org> on 
> behalf of Martin Smith <martin.sm...@qt.io>
> Sent: Friday, June 3, 2016 10:00:26 AM
> To: Edward Welbourne; André Somers; development@qt-project.org
> Subject: Re: [Development] commas in ctor-init-lists
> 
>> Please allow that,
> 
> I do, of course. Andre didn't. He wrote...
> 
>>> if (blah || boo || foo) {  //no line breaking allowed
> 
> ...with the comment.
> 
> ________________________________________
> From: Edward Welbourne
> Sent: Friday, June 3, 2016 9:54:43 AM
> To: Martin Smith; André Somers; development@qt-project.org
> Subject: Re: [Development] commas in ctor-init-lists
> 
> André
>>> So that means that our C++ code should look like this then?
>>> if (blah || boo || foo) {  //no line breaking allowed
> 
> Martin
>> In that case, yes, because the entire expression is short. And the
>> ctor example that was used originally would also be on one line. Why
>> not? Does the Qt coding standard require each expression to be on a
>> separate line? I thought they should be on separate lines when the
>> list is too long to be on a single line.
> 
> Please allow that, in giving illustrations, short texts may be used as
> surrogates for tacitly long ones, so that
> 
>  if (blah
>      || boo
>      || foo) {
>      some.code();
>  }
> 
> is tacitly standing for
> 
>  if (somee.really(long.and.complicated, expression)
>      || another.such(that, makes, the.line.too.long)
>      || and.then.some.more()) {
>      some.code();
>  }
> 
> in examples - it gets boring to write the examples out in full like that
> and I would hope everyone is capable of interpolating the big long ugly
> expressions for which short tokens are used in illustrations.
> 
>        Eddy.
> _______________________________________________
> Development mailing list
> Development@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
> _______________________________________________
> Development mailing list
> Development@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

-- 
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
eike.zil...@qt.io
+123 45 6789012
http://qt.io
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 
144331 B



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

Reply via email to