Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Jan 1999 22:29:11 -0800
From:      Don Lewis <Don.Lewis@tsc.tdk.com>
To:        Brian Somers <brian@Awfulhak.org>, Andrew Kenneth Milton <akm@zeus.theinternet.com.au>
Cc:        julian@whistle.com (Julian Elischer), mike@smith.net.au, dillon@apollo.backplane.com, archie@whistle.com, nate@mt.sri.com, current@FreeBSD.ORG
Subject:   Re: btokup().. patch to STYLE(9) (fwd)
Message-ID:  <199902010629.WAA07789@salsa.gv.tsc.tdk.com>
In-Reply-To: Brian Somers <brian@Awfulhak.org> "Re: btokup().. patch to STYLE(9) (fwd)" (Jan 29,  8:34am)

next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 29,  8:34am, Brian Somers wrote:
} Subject: Re: btokup().. patch to STYLE(9) (fwd)
} 
} My argument is that this sort of thing gets out of hand.  I've seen 
} things such as
} 
}   if (((a == b) || (c == d)))
} 
} where a, b, c & d are just simple variables - there are so many 
} redundant brackets that you have to double-check that there isn't 
} some weird grouping....

You can pretty clearly dump the outer parens, since it makes no sense
to write "(expression)" instead of "expression".  In general, "a OP b"
should not be parenthesized if both "a" and "b" are atoms unless the
context requires it.

In general my preferred style doesn't use parentheses in expressions
using "+-*/" according to their naturual precedence rules.  I might
drop the whitespace around "*", just like you'd write "2n" in mathematics.
Likewise, I don't use parentheses in logical expressions or bitwise
expressions where the terms are atoms.  Expressions used as terms in
logical expressions or comparision expressions might be parenthesized
if they are complicated so I can find the extent of the expression by
using '%' in vi.  I always parenthesize the interfaces between bitwise
and other expressions, since K&R admits that C botched the precedence
of the bitwise operators and this seems to be one common place for
bugs to occur.  In general, I always parenthesize non-atomic arguments to
the shift and ternary operators.



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199902010629.WAA07789>