lkml.org 
[lkml]   [2006]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH/v2] CodingStyle updates
On 12/15/06, Pavel Machek <pavel@ucw.cz> wrote:
> On Fri 2006-12-15 08:52:22, Scott Preece wrote
> >
> > I think the mistake illuminates why parentheses should be the rule. If
> > you're thinking about using spacing to convey grouping, use
> > parentheses instead...
>
> Not in simple cases.
>
> 3*i + 2*j should be writen like that. Not like
> (3 * i) + (2 * j)
---

Actually, my preference would be to use the parentheses AND drop the
spaces: (3*i)+(2*j) . But, existing kernel code seems to prefer just
using spaces and adding parentheses when it gets complicated. Note
that the mistake in your example was in a relatively simple
expression.

I think the unary operator case is a little different - it's not so
much to make precedence clear as just to help the reader chunk the
pieces of the string more naturally (at least, it's more natural to
anyone who's ever done anything object-oriented). I agree that your
spacing example, above, also helps that way, but it seems better to do
it in a way that's meaningful o the compiler as well as to the reader.

scott
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-12-15 17:19    [W:0.148 / U:1.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site