Hi.

I'm proposing to add some tool that automatically formats source code.

Main purpose is overall productivity. It's possible to save time on manual
formatting. Also, reading a uniformly formatted code is easier.

Some new languages has one correct coding style and code formatters.
Examples are Go (https://golang.org/cmd/gofmt/) and (to be done) Rust
(https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/guide.md).
I suggest to read 'Motivation - why use a formatting tool' from second link.

There is no single correct coding style in C and C++ worlds: different projects
use different styles if any at all. But there is a tool which does formatting
and supports different styles: clang-format.

It's a binary available for every major platform. It's configurable: just put
.clang-format file with formatting options in source directory and formatter
will use it for current and nested directories.

I actually do not propose here to use exactly clang-format but as I know it's
the best of its kind. Here is a demo https://youtu.be/uZI_Qla4pNA?t=1893

Tool is configurable but it will not act exactly as you might expect and this is
a pay for uniformity.

So, let's add .clang-format to root directory, start using and polishing style.
Here is some info on how to add it to some text editors 
https://clang.llvm.org/docs/ClangFormat.html

I do not(!) suggesting to reformat whole project. At least for now.

Here is my PR to add .clang-format files to server and InnoDB: 
https://github.com/MariaDB/server/pull/1270

I think that eventually .clang-format usage will lead to reformatting
everything and having some project-wide precommit hook which will properly
format your diffs.

Do you have any objections or questions on having such a tool?
Let's discuss, please.

-- 
Eugene


_______________________________________________
Mailing list: https://launchpad.net/~maria-developers
Post to     : maria-developers@lists.launchpad.net
Unsubscribe : https://launchpad.net/~maria-developers
More help   : https://help.launchpad.net/ListHelp

Reply via email to