[Development] commas in ctor-init-lists

Mathias Hasselmann mathias.hasselmann at kdab.com
Wed Jun 1 17:41:23 CEST 2016



Am 01.06.2016 um 15:15 schrieb Sergio Martins:
> 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
>> , but it looks butt
>> -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.
>
> Subjective reasons against leading commas:
> - It's ugly
>
> Subjective reasons against trailling commas:
> - It's ugly
>
> Objective reasons in favor of leading commas:
> - You get 1 line diffs
> - You can comment it out by commenting only 1 line
> - Code generators / tooling only have to touch 1 line to add or remove

Not mentioned yet: Conditional compilation vs. stable ABI:

     MamanBar::MamanBar(...)
         : m_field1(...),
           m_field2(...),	// oh...
#ifdef FEATURE1_ENABLED
           m_field3(...), 	// ...ah
#endif
#ifdef FEATURE2_ENABLED
           m_field4(...)
#endif
     {
     }


Ciao,
Mathias
-- 
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/e7a22463/attachment.bin>


More information about the Development mailing list