[vtk-developers] PROPOSAL: Changing VTK's indentation style
Brad King
brad.king at kitware.com
Wed Sep 9 17:29:16 EDT 2015
On 9/9/2015 3:41 PM, Brad King wrote:
> if (...) {
> ...
> } else {
> ...
> }
[snip]
> if (...)
> {
> ...
> }
> else
> {
> ...
> }
There seems to be agreement that either of these is an improvement
but that we should choose now which one to use. I'm sure one can
find endless debates across the web about which one is best. Here
are the main reasons I prefer the former over the latter:
1. Uses less vertical space. This is important when the content
within the blocks is short.
2. The start and end of each logical block is aligned horizontally
and can be matched vertically with nothing in the way:
if (...) {
^ ...
| ...
| ...
| ...
| ...
v ...
} else {
^ ...
| ...
| ...
| ...
| ...
v ...
}
This is important when the content within the blocks is long.
3. Distinguishes conditional and unconditional blocks:
if (...) {
// conditional block
}
{
// unconditional block
}
Contrast this to the latter style where both look the same:
if (...)
{
// conditional block
}
{
// unconditional block
}
In the latter style one must read a line above the "{" to see
whether it is a condition. This could be tricky if there is
an unrelated f(...) call there.
The former style is widely used in many projects and well-supported
by editors.
-Brad
More information about the vtk-developers
mailing list