Messages in this thread | | | Date | Fri, 15 Dec 2006 10:16:11 -0600 | From | "Scott Preece" <> | Subject | Re: [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/
| |