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-27 22:30:05 PST Path: supernews.google.com!sn-xit-03!supernews.com!news-feed.riddles.org.uk!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed2.earthlink.net!newsfeed.earthlink.net!news.mindspring.net!user-2iveaji.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 01:28:33 -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.2a.72 X-Server-Date: 28 Feb 2001 06:24:27 GMT Xref: supernews.google.com comp.os.vms:20467 comp.sys.dec:2895 In article <97hvro$hj4@freepress.concentric.net>, "Rick Cadruvi" wrote: > > > > But I think that is fine: > > > > if WINE = RED > > then > > .... > > elsif SIZE > 500 > > then > > .... > > elsif AGE /= 17 > > then > > .... > > else > > .... > > end if; > > Your example is fine. I am talking about something like: > > if () > {if () > { > } > else > { > if > { > } > else > { > } > } > } > else > > Its the extra nesting that gets problematic. Your example doesn't > display that type of behavior. Well, the C if is particularly weak, and brackets for statement grouping are error-prone. The Ada if is more robust and expressive. In Ada, small syntax errors are easier for the compiler to isolate and flag. The "elsif" construct reduces nesting depth in many situations. The if statement was one of the many points where the Ada designers tried to correct syntactic blunders from previous languages. "elsif" is an interesting example. "else if" and "elsif" mean quite different things (the former starts another level of nesting). They could have chosen "elseif" instead of "elsif", since blanks are significant in Ada. But that would have been hell on all the Fortran programmers, who can't tell the difference between ELSEIF and ELSE IF. In Ada, where line breaks are NOT significant, omitting the space might have been correct, or and error, but the compiler would not know which until the end of the whole block-if construct. The strangely-spelled "elsif" localizes what is a common typo for folks used to some other languages. > Even still, I would probably use other constructs like > a switch case statement or something. I'd tend to agree with you in C, where the if is feeble. In Ada, the if-elsif-else construct is the right one in most cases. In Larry's example, where the IF involves 3 different variables (WINE, SIZE, and AGE), CASE won't work. And if you need a nested if-else in both the if part and the else part, a switch isn't simple anymore. > > > Teach programmers to write code well, and new progrmaming languages will > > > evolve that help us solve the problems better and not ones that prevent > us > > > from > > > doing things we shouldn't do in the first place unless they are REALLY > > > required. > > > > But we seem to disagree on what constitutes well-written. > > Can we at least agree that if programmers were taught to write good code in > the first place then a lot of the problems some languages try to solve would > be less > of an issue? Yes, I'll agree with that any time. It's a problem that won't go away anytime soon. I think it's getting worse. (That must be a sign of oldness.) There have been some fairly unbiased side-by-side comparisons of productivity with C vs. Ada, at various programmer skill levels. Ada comes out ahead, usually by a large margin. It seems to take a bit longer to write, but much less time to debug. In the modern world, where bugs don't matter, Ada is at a disadvantage. -- Robert Deininger rdeininger@mindspring.com