From owner-freebsd-current Sun Jan 31 22:30:10 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA00203 for freebsd-current-outgoing; Sun, 31 Jan 1999 22:30:10 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from gatekeeper.tsc.tdk.com (gatekeeper.tsc.tdk.com [207.113.159.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA00196 for ; Sun, 31 Jan 1999 22:30:08 -0800 (PST) (envelope-from gdonl@tsc.tdk.com) Received: from sunrise.gv.tsc.tdk.com (root@sunrise.gv.tsc.tdk.com [192.168.241.191]) by gatekeeper.tsc.tdk.com (8.8.8/8.8.8) with ESMTP id WAA28055; Sun, 31 Jan 1999 22:29:15 -0800 (PST) (envelope-from gdonl@tsc.tdk.com) Received: from salsa.gv.tsc.tdk.com (salsa.gv.tsc.tdk.com [192.168.241.194]) by sunrise.gv.tsc.tdk.com (8.8.5/8.8.5) with ESMTP id WAA09960; Sun, 31 Jan 1999 22:29:13 -0800 (PST) Received: (from gdonl@localhost) by salsa.gv.tsc.tdk.com (8.8.5/8.8.5) id WAA07789; Sun, 31 Jan 1999 22:29:11 -0800 (PST) From: Don Lewis Message-Id: <199902010629.WAA07789@salsa.gv.tsc.tdk.com> Date: Sun, 31 Jan 1999 22:29:11 -0800 In-Reply-To: Brian Somers "Re: btokup().. patch to STYLE(9) (fwd)" (Jan 29, 8:34am) X-Mailer: Mail User's Shell (7.2.6 alpha(3) 7/19/95) To: Brian Somers , Andrew Kenneth Milton Subject: Re: btokup().. patch to STYLE(9) (fwd) Cc: julian@whistle.com (Julian Elischer), mike@smith.net.au, dillon@apollo.backplane.com, archie@whistle.com, nate@mt.sri.com, current@FreeBSD.ORG Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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