From owner-freebsd-hackers Wed Mar 6 2:44:51 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mired.org (dsl-64-192-6-133.telocity.com [64.192.6.133]) by hub.freebsd.org (Postfix) with SMTP id 764C537B416 for ; Wed, 6 Mar 2002 02:44:46 -0800 (PST) Received: (qmail 71294 invoked by uid 100); 6 Mar 2002 10:44:44 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15493.62234.943657.776598@guru.mired.org> Date: Wed, 6 Mar 2002 04:44:42 -0600 To: Poul-Henning Kamp Cc: "Mike Meyer" , obrien@FreeBSD.ORG, Mike Meyer , Giorgos Keramidas , hackers@FreeBSD.ORG Subject: Re: RFC: style(9) isn't explicit about booleans for testing. In-Reply-To: <30203.1015411062@critter.freebsd.dk> References: <15493.61384.557931.883967@guru.mired.org> <30203.1015411062@critter.freebsd.dk> X-Mailer: VM 6.90 under 21.1 (patch 14) "Cuyahoga Valley" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ From: "Mike Meyer" X-Delivery-Agent: TMDA/0.48 (Python 2.2 on freebsd4) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Poul-Henning Kamp types: > Ahh, but here you hit one of my pet-peeves. I hate assignments inside > conditionals. I prefer the above written as: > Anyway, if you want it spelled out the way I would want it: > > 0. No assignments in if() > > 1. In conditions, pointers should be explicitly compared against NULL: > > if (foo == NULL) > or > if (foo != NULL) > > 2. In conditions, non-interger numeric types should be explicitly compared > to zero > > if (float_t == 0.0) > > 3. Integers need not be explicitly compared to zero: > > if (foo & MASK) > not > if ((foo & MASK) != 0) I would like it spelled out. Since style(9) uses assignments in conditionals in it's examples, rule 0 probably won't fly. Rule 1 and 2 are redundant. Looking at the text in the page on -stable, I think the one-word change from boolean to "integer" would remove the ambiguity. Thank you, http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message