On Wed, Jan 13, 2016 at 03:58:49PM +0800, Yuanhan Liu wrote: > Using two tabs for "if" (or "while") statements is a bit weird to me. > Also, using one tab unconditionaly for function definitions and > prototypes doesn't look great. > > Here I'd suggest to use the indentation style the Linux kernel > project prefers: to align with the open brace with tabs and > additonal spaces (when necessary). > > Example: > > static int > rte_eal_foo_bar(int a_long_argument_1, int another_long_argument_2, > struct foo *yet_another_long_argument_3) > > ret = rte_eal_foo_bar(a_long_argument_1, another_long_argument_2, > yet_another_long_argument_3); > > if (really_long_variable_name_1 == really_long_variable_name_2 && > var3 == var4) { > x = y + z; > ....; > } > > Cc: Thomas Monjalon <thomas.monjalon at 6wind.com> > Cc: Siobhan Butler <siobhan.a.butler at intel.com> > Cc: John McNamara <john.mcnamara at intel.com> > Signed-off-by: Yuanhan Liu <yuanhan.liu at linux.intel.com> > ---
While it's not a big deal - yet is something likely to trigger massive discussion my objections to this style of indentation is two-fold: 1. It means that we are using a mix of tabs and spaces for indentation at the start of a line. I think it's more consistent that all whitespace at the start of a line should be either tabs or spaces, but not a mixture. 2. It makes how the code look much more dependent upon the tab-size being used in the viewer - being able to adjust how much whitespace is seem at the start of each line is a major advantage of using tabs rather than spaces for indentation. For anyone using a 4-character tabstop - probably the most popular tabstop value after an 8-char one - aligning an if-statement continuation to the opening brace will cause it to align with the body of the block. So, while the two-tab indent may look "a bit weird" it does solve the two issues above. I believe practical benefits should override initial impressions. [It took me a while to get used to also, but now I very much like it as a style.] Regards, /Bruce