From owner-freebsd-chat Tue Jan 23 7:59:24 2001 Delivered-To: freebsd-chat@freebsd.org Received: from mail.bfm.org (mail.bfm.org [216.127.218.26]) by hub.freebsd.org (Postfix) with ESMTP id 2A47537B6A1 for ; Tue, 23 Jan 2001 07:59:06 -0800 (PST) Received: from WhizKid (r41.bfm.org [216.127.220.137]) by mail.bfm.org (Post.Office MTA v3.5.3 release 223 ID# 0-52399U2500L250S0V35) with SMTP id org; Tue, 23 Jan 2001 10:01:08 -0600 Message-Id: <3.0.6.32.20010123095930.00a14550@mail85.pair.com> X-Sender: whizkid@mail85.pair.com X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Tue, 23 Jan 2001 09:59:30 -0600 To: Jonathon McKitrick From: "G. Adam Stanislav" Subject: Re: C style continued.... (Craig and Terry) Cc: freebsd-chat@FreeBSD.ORG In-Reply-To: References: <3.0.6.32.20010123091354.009de7c0@mail85.pair.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org At 10:16 23-01-2001 -0500, Jonathon McKitrick wrote: >> > if (0 == i) { >> > foo(i); >> > bar(i); } >> >> Of course, the whole problem with this example is not the formating >> style, but the unnecessary use of a variable. It should be changed to: >> >> if (!i) {foo(0); bar(0);} > >Except that 'style' says we should not use '!' for tests, unless the >variable is declared boolean. Otherwise, compare with 0. I wrote that half seriously, half toungue in cheek. But in K&R style (!i) is perfectly acceptable. I use it. If I were writing code for FreeBSD core, I would not use it because I would respect the requested style. But in my own software, I take all the shortcuts I can. As I said in another message, to me all data is just binary. Besides, last I checked, there was no intrinsic boolean type in C anyway. At any rate, I'd just code the whole thing something like this: mov ecx, [esp+4] jecxz .skip push ecx call foo call bar pop ecx .skip: ret Who needs variables when there are registers. And who needs to push 0 twice. ;) Cheers, Adam --- Whiz Kid Technomagic - brand name computers for less. See http://www.whizkidtech.net/pcwarehouse/ for details. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message