From: Bruce Richardson <bruce.richardson@intel.com>
To: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] doc: coding style: use linux kernel style for indentation
Date: Wed, 13 Jan 2016 15:07:08 +0000 [thread overview]
Message-ID: <20160113150708.GD7756@bricha3-MOBL3> (raw)
In-Reply-To: <1452671929-29617-1-git-send-email-yuanhan.liu@linux.intel.com>
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@6wind.com>
> Cc: Siobhan Butler <siobhan.a.butler@intel.com>
> Cc: John McNamara <john.mcnamara@intel.com>
> Signed-off-by: Yuanhan Liu <yuanhan.liu@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
next prev parent reply other threads:[~2016-01-13 15:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-13 7:58 Yuanhan Liu
2016-01-13 15:07 ` Bruce Richardson [this message]
2016-01-13 16:49 ` Stephen Hemminger
2018-02-13 12:51 ` Ferruh Yigit
2018-02-13 13:12 ` Yuanhan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160113150708.GD7756@bricha3-MOBL3 \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=yuanhan.liu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).