From owner-freebsd-hackers Tue Mar 5 23:34:29 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by hub.freebsd.org (Postfix) with ESMTP id 149E537B405; Tue, 5 Mar 2002 23:34:26 -0800 (PST) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.2/8.12.2) with ESMTP id g267Y4Lv088753; Wed, 6 Mar 2002 08:34:09 +0100 (CET) (envelope-from phk@critter.freebsd.dk) To: "Mike Meyer" Cc: obrien@FreeBSD.ORG, Giorgos Keramidas , hackers@FreeBSD.ORG Subject: Re: RFC: style(9) isn't explicit about booleans for testing. In-Reply-To: Your message of "Wed, 06 Mar 2002 01:19:31 CST." <15493.49923.458997.98416@guru.mired.org> Date: Wed, 06 Mar 2002 08:34:04 +0100 Message-ID: <88752.1015400044@critter.freebsd.dk> From: Poul-Henning Kamp 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 In message <15493.49923.458997.98416@guru.mired.org>, "Mike Meyer" writes: >David O'Brien types: >> On Wed, Mar 06, 2002 at 02:08:07AM +0200, Giorgos Keramidas wrote: >> I was giving one. :-) >> style(9) documents the practices of /sys. Thus we should not arbitaryly >> add rules w/o them being backed up in code. > >As the original author of the PR, I'll point out that this chagne does >*not* add rules. It clarifies the wording of a rule that's already >there. If the rule is wrong, it should be removed. The reason I didn't >post if for wider review was because it wasn't changing any rules. My >thanks to Giorgos for moving this PR towards closure. I had a discussion with Eric Allman about this very thing recently where he advocated "everything inside if, while, for and so on should be true booleans". Now, IFF the C language had a type called "boolean" that would make a lot of sense. Unfortunately, it does not (at present ?) have a boolean type, and while one could simulate it with typedefs, there is no way to get the compiler to enforce the rule. I belive the overall purpose of style(9) is to make the code readable, and I happen to think that if (somerandomfunction(argthis, functionthat(something), onemore)) { chugchugchug(argthisa; } is just a tiny bit more readable than if ((somerandomfunction(argthis, functionthat(something), onemore) != 0) { chugchugchug(argthisa; } for instance. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message