There _is_ consensus. It's in the wiki. And in older modules not
infected by the _clang-format file. Discussions arise because
of .clang-format, not despite it. Afaict, there never was a discussion
about how faithful the _clang-format represents the Qt style before it
was added. If there was _any_ attempt at the above-mentioned litmus
test, the template<> issue and others would have been detected immediately.

Unfortunately the consensus is weak on the most jarring problem, and that happens to be one that the automatic formatters I know are utter rubbish at:

Where do you break the line and how much white space do you indent in various situations? For example:

* long lists of arguments list to a function (call or declaration)
* nested template parameters, possibly with defaults
* template arguments
* lists of partially specialized template parameters
* initializer lists (possibly nested)
* ternary operators with outsized "hands"
* constructor-initializers
* lambdas, potentially nested
* nested boolean or arithmetic expressions with or without parentheses
* and then combine all of those

I find myself constantly re-indenting things based on some unwritten rules I make up myself. I would be fine with an automatic indentation that produces somewhat readable code, but what I get is frequently an indentation to column 205 or similar for no obvious reason.

Yes, it often helps to use additional temporaries so that your lines are not as large to begin with. However, that also increases the cognitive load when reading it as you then have to carefully determine if the introduction of the temporary changes semantics. For example, is the temporary moved or copied? Does the extracted template construction allow things the inline one was not meant to allow? etc.

All the other stuff you may format for is trivial in comparison because it only involves adding or removing few characters here or there. With some practice it takes up rather little time, even when done manually. The indentation, however, requires shifting around large bodies of white space, which is quite annoying in the editors I know.

best regards,
Ulf
--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to