[Development] commas in ctor-init-lists

Martin Smith Martin.Smith at qt.io
Fri Jun 3 10:22:46 CEST 2016


>My earliest encounters with this style were well into the present
>millennium and I am fairly sure they were motivated by the relative ease
>of fitting with #if-ery near the end of an initializer list, as has been
>illustrated by a few advocates of this style.

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.

martin
________________________________________
From: Edward Welbourne
Sent: Friday, June 3, 2016 10:14:38 AM
To: Martin Smith; André Somers; development at qt-project.org
Subject: Re: [Development] commas in ctor-init-lists

> 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?

My earliest encounters with this style were well into the present
millennium and I am fairly sure they were motivated by the relative ease
of fitting with #if-ery near the end of an initializer list, as has been
illustrated by a few advocates of this style.  As a few others have
commented, I found it perverse at first but got used to it fairly
swiftly.  I strongly suspect the #if-ery argument is what first prompted
someone to want to do this, but I imagine the invention of this style is
lost in the mists of time.

Incidentally, the problem with this style at the start of an initializer
list can usually be overcome by including a base-class construction
explicitly, despite its being fatuous:

Derived::Derived(type arg)
  : Base() // fatuous and unnecessary, but accommodates:
#if FEEPING
  , creature(itis)
#endif
  , etc(arg)

Not that I wish to particularly advocate either side of the debate; I'd
just rather both sides' cases were properly and clearly stated ...

        Eddy.



More information about the Development mailing list