From owner-cvs-all Thu Mar 7 6:36:25 2002 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id CD7D037B405; Thu, 7 Mar 2002 06:36:11 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id BAA24877; Fri, 8 Mar 2002 01:35:50 +1100 Date: Fri, 8 Mar 2002 01:36:51 +1100 (EST) From: Bruce Evans X-X-Sender: To: Mark Murray Cc: , Will Andrews , , Subject: Re: cvs commit: src/usr.bin/rwall rwall.c In-Reply-To: <200203071316.g27DGlRV011103@grimreaper.grondar.org> Message-ID: <20020308012014.Q1004-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, 7 Mar 2002, Mark Murray wrote: > > On Thu, Mar 07, 2002 at 12:06:49PM +0000, Mark Murray wrote: > > > > 2. please review the C idiom of short-circuit evaluation. > > > > > > I know this. See style(9) on complicated expressions. > > > > Please point out which section you are referring to. I glanced thru > > style(9) wondering if the if() style changes are mandated. Searching on > > "assignment" or "complicated" gave nothing. And the examples such as: > > > > if ((four = malloc(sizeof(struct foo))) == NULL) > > > > seem to approve the style. > > (Lousy) example. I hate it when examples become rules. > > The section I was referring to is: > > Unary operators do not require spaces, binary operators do. Do not use > parentheses unless they are required for precedence or unless the state- > ment is confusing without them. Remember that other people may confuse > easier than you. Do YOU understand the following? > > a = b->c[0] + ~d == (e || f) || g && h ? i : j >> 1; > k = !(l & FLAGS); This is a silly example which made more sense before it was explained in rev.1.23. You weren't meant to understand this. It is a random C expression that needs parentheses and perhaps splitting up because it is very far from the C idiom. The expression that was broken in rwall.c is the oppposite. It is idiomatic, so it is easier to understand when it is not split up. OTOH, the simpler expression for `four' above doesn't benefit much from being written on one line, since it doesn't need the `||' idiom. rev.1.23 still objected to by: bde Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message