[vtk-developers] style : Holiday greetings and a present of VTK4.0

Ken Martin ken.martin at kitware.com
Fri May 25 09:58:55 EDT 2001


Clearly there are two main camps of indentation style and over the
past decades there have been bloody wars fought over the issue. After
hearing all the arguments for having the brace on the same line, I
still can't fathom why anyone would sacrifice the readability of the
brace-on-the-next-line style for it. To me it is like saying "If I use
one letter variables I can fit more code on a line" That is why there
are two camps. If there was a clear better solution people would not
be divided on the issue. But different people look at code and think
differently and so they have different opinions. And I don't think one
brace style introduce significantly more bugs than the other, unlike
the

if ()
  macro();

versus

if ()
  {
  macro();
  }

issue. I do believe that either style is better than a mix of the two.
Having code that switches between styles from line to line would be
difficult to read, and over time if we supported both, that is what
would happen. Anyhow, I have thrown in the emacs code I use for VTK
below. I have no idea if this is the best emacs code or even correct.
The indent-tabs-mode seems to replace tabs with spaces and a similar
setting can be made in MSVC++ which should help that issue. The other
statements provide the VTK indentation style.


(set-default 'indent-tabs-mode nil)

(setq c-basic-offset 2)
(setq c-default-style "user")

(defun kens-c-statement-block-intro (langelem)
  ;; indent by c-basic-offset only if in column 1
  (save-excursion
    (back-to-indentation)
    (if (=
	 (save-excursion
	   (re-search-backward "{" 1) (current-column)) 0)
	c-basic-offset
      ;; otherwise dont indent
      0)))
(c-set-offset 'statement-block-intro 'kens-c-statement-block-intro)







More information about the vtk-developers mailing list