Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxr!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!tektronix!reed!kab From: kab@reed.UUCP (Kent Black) Newsgroups: net.lang.c Subject: Re: What should be added to C Message-ID: <3613@reed.UUCP> Date: Wed, 11-Jun-86 13:22:05 EDT Article-I.D.: reed.3613 Posted: Wed Jun 11 13:22:05 1986 Date-Received: Sun, 15-Jun-86 06:31:42 EDT References: <1462@mmintl.UUCP> <5498@alice.uUCp> <1497@mmintl.UUCP> <779@steinmetz.UUCP> Reply-To: kab@reed.UUCP (Kent Black) Organization: Reed College, Portland, Oregon Lines: 76 In article <779@steinmetz.UUCP> davidsen@kbsvax.UUCP (Davidsen) writes: >In article <1497@mmintl.UUCP> franka@mmintl.UUCP (Frank Adams) writes: >>In article <5498@alice.uUCp> ark@alice.UUCP writes: >>>Frank Adams says: >>>> o An andif clause for if statements. >> >>You would write: >> >> if (A) { >> X >> } andif (B) { >> Y >> } else { >> Z >> } >> >>This is equivalent to: >> >> if (!(A)) goto _Z; >> X >> if (B) { >> Y >> } else { >>_Z: >> Z >> } > >*you* might do that, but most people would nest the "if (B)" after the >"if (A)". > > if (A) { > X > if (B) { > Y > } /* if (!B) ??? */ > } else { > Z > } > Yep, I was there among "most people"; unfortunately, it isn't the same code. The original can be rewritten as: if (A) { X; if (B) Y; else goto _Z; } else { _Z: /* this deserves a comment! :-) */ Z; } Flow of control is to 'Z' on (!A) OR (!B). If gotooz are anathema, flags can be used, e.g., aflag = bflag = FALSE; if (A) { aflag = TRUE; X; if (B) bflag = TRUE; Y; } if (aflag == FALSE || bflag == FALSE) { Z; } ----------------- My apologies to Bill Davidsen for not digging out my own posting, to Frank Adams for not reading carefully and to the rest of the net. ----------------- Kent Black (...tektronix!reed!kab)