Date: Wed, 06 Mar 2002 08:34:04 +0100 From: Poul-Henning Kamp <phk@critter.freebsd.dk> To: "Mike Meyer" <mwm-dated-1015831171.a21ab0@mired.org> Cc: obrien@FreeBSD.ORG, Giorgos Keramidas <keramida@FreeBSD.ORG>, hackers@FreeBSD.ORG Subject: Re: RFC: style(9) isn't explicit about booleans for testing. Message-ID: <88752.1015400044@critter.freebsd.dk> In-Reply-To: Your message of "Wed, 06 Mar 2002 01:19:31 CST." <15493.49923.458997.98416@guru.mired.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In message <15493.49923.458997.98416@guru.mired.org>, "Mike Meyer" writes: >David O'Brien <obrien@freebsd.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?88752.1015400044>