From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,8be18979db11f51c X-Google-Attributes: gidf7344,public X-Google-Thread: 1164f8,fb631c9316319fef X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 2001-02-28 12:03:28 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!falcon.america.net!newspump.monmouth.com!newspeer.monmouth.com!feed2.onemain.com!feed1.onemain.com!newsfeed2.earthlink.net!newsfeed.earthlink.net!news.mindspring.net!user-2ivec5g.dialup.mindspring.com!user From: rdeininger@mindspring.com (Robert Deininger) Newsgroups: comp.os.vms,comp.sys.dec Subject: Re: Drop C/C++ better sooner than later Date: Wed, 28 Feb 2001 15:01:03 -0500 Organization: MindSpring Enterprises Message-ID: References: <87n1baae6s.fsf@prep.synonet.com> <97bm3a$7tv@gap.cco.caltech.edu> <3A99AED0.5DF07890@infopuls.com> <97cd06$hcn$1@pyrite.mv.net> <97egck$vc6$3@info.cs.uofs.edu> <3A9AEFCD.AFC8431@infopuls.com> <97etsu$j41$1@pyrite.mv.net> <3A9B023A.CBD414A5@infopuls.com> <97hvro$hj4@freepress.concentric.net> NNTP-Posting-Host: a5.f7.30.b0 X-Server-Date: 28 Feb 2001 19:59:23 GMT Xref: supernews.google.com comp.os.vms:20576 comp.sys.dec:2933 In article , Kilgallen@eisner.decus.org.nospam (Larry Kilgallen) wrote: > In article , rdeininger@mindspring.com (Robert Deininger) writes: > > > And if you need a nested if-else in both the if part and the else part, a > > switch isn't simple anymore. > > But something like: > > if WINE = RED > then > if MOON = FULL > then > ACTION_1; > else > ACTION_2; > end if; > elsif SIZE > 500 > then > if SEASON = SPRING > then > ACTION_3; > else > ACTION_4; > end if; > else > if OS = VMS > then > ACTION_5; > else > ACTION_6; > end if; > end if; > > Can be deconstructed into: > > if WINE = RED and MOON = FULL > then > ACTION_1; > elsif WINE = RED > then > ACTION_2; > elsif SIZE > 500 and SEASON = SPRING > then > ACTION_3; > elsif SIZE > 500 > then > ACTION_4; > elsif OS = VMS > ACTION_5; > else > ACTION_6; > end if; > > Remember that at this level it is the job of the compiler > and not the programmer to perform optimization. The two > examples above are quite likely to produce the same machine > code (presuming I made no error in deconstruction). Right. You can trade "deep" vs. "wide" in a construct like this. I think I prefer your second one at the moment; elsif's are good, and the second fragment uses more of them. But this is a horrible contrived example, and if I saw real code like this I would be tempted to look for a bigger reorganization. I would never choose one over the other based on what the compiler would do with them. That's not my job. I see you are one of those "then under if" folks. I've never understood that. :-) But neither example really looks like a C-style switch. I was arguing _for_ the block-if construct, not the other way round. Certainly in Ada, the CASE won't get you as far as the switch will in C. -- Robert Deininger rdeininger@mindspring.com