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 08:34:02 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!199.60.229.5!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!sjc1.nntp.concentric.net!newsfeed.concentric.net!global-news-master From: "Rick Cadruvi" Newsgroups: comp.os.vms,comp.sys.dec Subject: Re: Drop C/C++ better sooner than later Date: 28 Feb 2001 16:28:48 GMT Organization: Concentric Internet Services Message-ID: <97j900$ppc@dispatch.concentric.net> 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> <3A9C2B88.8032D829@infopuls.com> <97ivjt$96k$1@soap.pipex.net> NNTP-Posting-Host: 64.0.157.124 X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: supernews.google.com comp.os.vms:20531 comp.sys.dec:2915 > > 2. SWITCH/CASE doesn't auto-break. I NEVER depend on being able > > to fall through to the next CASE in a SWITCH statement. The > > default should be BREAK and allow specifying CONTINUE if you > > want to drop through. THIS IS A BIG PROBLEM!!! > > I would have to say NO! > > I use this feature from time to time, and when needed it can very useful, > and saves unnecessary tests and duplicated code. Apart from that I think > that I cannot remember when a missing "break" caused me any problems the > last time, it was so long ago. > > Also "continue" has a completely defined and simple function. > BREAK could be defined to only deal with loops too, but it is used in SWITCH/CASE. There is no reason CONTINUE couldn't be used as well. My point is only that the NORMAL use is to BREAK after a case rather than dropping down. The default should always be the normal usage, not the exception in my view. > > > > 3. BREAK. Break should be allowed from ALL Begin/End ({}) > > constructs (including IF ELSE). You should also be able to > > BREAK # where # is the number of Begin/End blocks you want > > to break out of. > > Sorry but this is about the most horrible suggestion for any language I have > ever seen. The thing a language should do is provide the tools to make the code as simple as possible. Many times you get inside of something and you really want to get out of multiple levels. If the point is that the BREAK # has to be a constant number rather than a variable, I agree entirely. However, setting and testing flags to exit levels makes for more code and makes bugs more likely. The real problem is not when you are writing the code, but when someone else comes along to maintain the code and misses the flags. Here's an example: for (i = 0, i < 10; i++) { if (condition[i] == TRUE) { for (j = 0; j < 5; j++) { if (stuff[j] == FALSE) break 3 // Get me out } } } I know the example is simplistic, but if expanded into more involved code, the value of the contruct becomes more clear. The truth is that I would probably have made the inner loop a function call and the problem goes away. What I am saying is that occasionally, I would like to be able to leave more than a single BEGIN/END. Also, I would like to be able to leave an IF or ELSE BEGIN/END early sometimes to simplify the code. > > Next you'll suggest that a computed goto's like in Fortran would be nice. > This would be event worse than using goto in you code (goto is completely > band by our C/C++ coding standards), this would make maintaining code hell, > every little modification to a module a hazard, causing untold problems if > just one break# was missed and not updated. > > Simply speaking if your code is that complex try splitting it into separate > functions, and check your logic. Agreed. Absolutely right. No I wouldn't want computed GOTOs > > > > > 4. Use of "==" for compares. It's WAY too easy to put in "=" > > instead. In fact, I usually do a specialized search of ALL > > my code before the first compile just to try and catch these. > > > > I used to make that mistake when I first started in C (about 15 years ago), > but I soon got over it. Yes this occationally stoll happens, but usually the > effect is quite obviouse within the first hour or so of testing. Also many > modern compilers do warn of this at compilation time now, so the problem is > not like it was. I still slip once in awhile and I have as many C years under my belt as you. Maybe my brain just locks up once in awhile. I have noticed my fingers get dylexsia once in awhile, perhaps my brain does also. My point is only that it was a BAD choice of operators in my opinion that has the poitential of causing bugs. > > I have been writing in C and more recently some C++ for about 15 years, and > I will admit that I have seen some awful code written in both languages. The > problem with bad code, which is difficult to follow, overly complicated, not > commented, and just down right sloppy, has almost nothing to do the language > in my view. > Absolutely correct. This is actually the starting point of the whole discussion thread.