Position of const keyword

Asked by Gabriel Margiani on 2013-02-06

In the last reviews, SirVer asked to write the const keyword in front of the definition
const T v, not T const v.

The style guidelines given on the website contain the opposite of this
(http://www.s.kth.se/sigra/widelands-economy-documents/Guidelines_for_writing_good_C++_sourcecode.html#placement_of_const_keyword)
Could the guidelines get updated?

Maybe we should add a Style rule or, at least, say somewhere that the the style used
in most of the code isn't what is expected from new code. So new developers don't need to
wonder why the style used in all code around their change should be wrong.

Question information

Language:
English Edit question
Status:
Solved
For:
widelands Edit question
Assignee:
No assignee Edit question
Solved by:
SirVer
Solved:
2013-02-06
Last query:
2013-02-06
Last reply:
2013-02-06
Best SirVer (sirver) said : #1

Erik (sigra) has not contributed to widelands in a long time - I remember him starting a job, I think he just ran out of time. The stuff is on his server and only he can update. I feel that the guide is very outdated and we should no longer link to it (feel free to remove it from the wiki/code).

Style is a difficult topic - the best solution to it has the go language which comes with a formatting tool that enforces one style.

For Widelands, we established the style checkers to get some homogeneity - I think we succeeded and they do more good than harm at this point in time. However, the world moved on and I am now using clang-format [1] with great success at work and in other projects and do not care a lot about style anymore - let the tools do it. I am meaning to get a configuration to have it work for Widelands as well (help is very welcome). Currently what it does makes our code checkers bark, but I believe that we can get to a point where we just can let it run over the whole codebase and get a singular style. We also do this at work with success and emulate the way you would work in go.

[1] http://clang.llvm.org/docs/ClangFormat.html

Gabriel Margiani (gamag) said : #3

Thanks SirVer, that solved my question.