On 07/03/2018 10:26 AM, Lars Knoll wrote:
On 2 Jul 2018, at 16:52, Tor Arne Vestbø <[email protected]
> <mailto:[email protected]>> wrote:
>
>
>
>> On 2 Jul 2018, at 16:49, Lars Knoll <[email protected] >> <mailto:[email protected]>> wrote:
>>
>>
>>> On 2 Jul 2018, at 13:35, Tor Arne Vestbø <[email protected] >>> <mailto:[email protected]>> wrote:
>>>
>>>
>>>> On 2 Jul 2018, at 12:56, Svenn-Arne Dragly <[email protected] >>>> <mailto:[email protected]>> wrote:
>>>>
>>>> There are also many nice options set in the clang-format config found in Qt >>>> Creator's sources[2] which I think are interesting. For instance, >>>> "BinPackParameters: false" and "BinPackArguments: false" makes sure you to >>>> either put all arguments on one line or give if arguments will have one >>>> line each. This might be in the controversial category, but it is nice to >>>> enable while developing. It makes clang-format reflow the code consistently >>>> just by moving a single argument to a new line and running clang-format >>>> afterwards.
>>>
>>> I oppose mandating this style, through clang-format or otherwise.
>>
>> Having a common style that we start following is worth something. And yes, >> everybody will always find some details he won't like. So we won't get >> anywhere if everybody wants it exactly his way.
>
> Why not ease into this with the non-controversial style-rules first?

clang-format will produce one way how the output is formatted. It will reformat
your sources a certain way with less definitions in the file as well. So it's
most likely better to have more rules defined as it'll give something closer to
our implicitly used coding style.

Cheers,
Lars

Not necessarily. With fewer options set, clang-format does leave some things as is, so the output is not always the same. For instance, if you leave "BinPackArguments" unset and set "ColumnLimit: 0", clang-format will respect your choices regarding argument placement. The following code is for instance kept intact in that case:

    auto result = myFunction(arg1, arg2,
                             argument3, arg4, argument5,
                             0, nullptr);

And similarly, this is kept intact:

    auto result = myFunction(arg1, arg2, argument3, arg4,
                             argument5, 0, nullptr);

Setting "BinPackArguments: false" or "ColumnLimit: 100" does on the other hand make clang-format reformat the above function call accordingly.

I agree with you, Tor Arne. I think it is better to start out with a config with only uncontroversial settings enabled. This already gets us pretty far and we'll have fewer arguments about style. And to be clear, I also don't want to mandate setting "BinPackArguments: false". I wanted to mention it because I found it nice to enable locally, even though it is far from perfect. If anything should be mandated with regards to argument placement, it should probably be more sophisticated or simply rely on a fixed column count.

However, a comprehensive clang-format config would be the best in the long run. So even though I think we should start with a minimal config, I also think we should start discussing the controversial options in separate threads/code reviews. Going through the different options in Creator's config is a good start.

Svenn-Arne

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to