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-03-01 03:57:47 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!hub.org!hub.org!ptdnetP!newsgate.ptd.net!newsfeed00.sul.t-online.de!t-online.de!join.news.pipex.net!pipex!grot.news.pipex.net!pipex!tube.news.pipex.net!pipex!not-for-mail From: "LJEB" Newsgroups: comp.os.vms,comp.sys.dec Subject: Re: Drop C/C++ better sooner than later Date: Thu, 1 Mar 2001 11:54:07 -0000 Organization: UUNET WorldCom server (post doesn't reflect views of UUNET WorldCom Message-ID: <97ld8a$e1e$1@soap.pipex.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> <97j900$ppc@dispatch.concentric.net> NNTP-Posting-Host: news.axl.co.uk X-Trace: soap.pipex.net 983447626 14382 194.201.74.40 (1 Mar 2001 11:53:46 GMT) X-Complaints-To: abuse@uk.uu.net NNTP-Posting-Date: 1 Mar 2001 11:53:46 GMT X-Priority: 3 X-MSMail-Priority: Normal 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:20673 comp.sys.dec:2959 "Rick Cadruvi" wrote in message news:97j900$ppc@dispatch.concentric.net... > > > 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. > I understand what you are getting at here, and to some degree, I agree. For instance when I use this fall through I nearly always have a comment with: /* DON'T BREAK HERE */ So the next programmer knows for certain that I want to carry on, and that it was not an omission. It is likely that my use of C has something to do with my outlook, a lot of work that I do is handling and decoding data feeds (e.g.: processing data received from stock exchanges). Just like the washing machine example posted here, there are often places where you need to select a start point, and then continue until the end or an exception it found. Also I use the following a lot: switch( value ) { case value_a: case value_b: case value_c: case value_d: /* common code for this set of values */ break; case value_e: case value_f: /* common code for this set of values */ break; default: break; } For me having to remember to add all the appropriate CONTINUE statements is just as bad as you see the opposite 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( other_condition ) { /* see trailing comment */ > if (condition[i] == TRUE) > { > for (j = 0; j < 5; j++) > { > if (stuff[j] == FALSE) break 3 // Get me out > } > } } /* it become too easy to break with a simple additions */ > } > > 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. As you said, normally you put this inner loop into a function. The fact that you cannot do the break# thing, in my view actually forces the programmer to write code that is easier to maintain. As many of the faults you and other see with this language are that they let programmers write code that is difficult to maintain, this addition would just give your novice another way to write horrible code. Adding something that you might occasionally us, would not stop it from being abused to a point that it would soon be regarded as something that should never have been there. Personally I think that GOTO should just be removed from the language (or at least make compilers complain about it use). I have not even wanted to use all the time I have written in C/C++, and the only times I have seen it used was because a routine was just too big (ie: should have been broken down into proper functional units). Laurence.