home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!decwrl!deccrl!news.crl.dec.com!rdg.dec.com!decvax.dec.com!enigami.mv.com!enigami.mv.com!cory
- From: cory@enigami.mv.com (Cory Kempf)
- Newsgroups: comp.lang.c++
- Subject: Re: named loops
- Message-ID: <0105011F.c24g8d@dragon.enigami.mv.com>
- Date: 26 Aug 92 15:48:41 GMT
- Reply-To: cory@enigami.mv.com
- Organization: EnigamI, Inc., Nashua, NH
- Lines: 55
- X-Mailer: uAccess - Macintosh Release: 1.6v1
-
-
- In article <1992Aug24.161012.2835@taumet.com> (comp.lang.c++), steve@taumet.com (Steve Clamage) writes:
- >bevan@cs.man.ac.uk (Stephen J Bevan) writes:
-
- >Second (a bit of nit-picking), the current "break" does not require a
- >label, whereas "goto" does. The proposed change adds a label to
- >the main code and thus also to the "break". This seems to me quite
- >similar syntactically to the "goto", as shown in the example above.
-
- A major difference is that the proposed change impliments a very highly
- rigidly defined implimentation of a goto. As I pointed out in a pervious
- article on the subject, just about ever control structure is a form
- of if/goto. Defining a proposed change as being bad because it is
- a form of goto would imply that all loops, switch statements, exception
- handling, etc are also likewise bad.
-
- All of these structures are essentually if/goto combinations, with
- very rigid rules for how they can be used. As such, they make the
- code cleaner, and easier to read, because we know what the rules are
- for a while loop, for example. Goto's have very few rules. When
- you see a goto in code, you know that execution is jumping somewhere.
- Where?
-
- >The difference is the location of the label and whether there is a
- >colon following it. For better diagnostics in the presence of syntax
- >errors and for consistency, it could be argued that the loop label
- >should have a colon anyway.
-
- Actually, this would be a bad idea. In a case statement, execution
- goes to the code imediately following the colon. In a goto, execution
- goes to the code imediately following the colon.
-
- With a named loop, upon encountering a continue, execution goes on
- to the next cycle, which begins somewhat after the label (especially
- in the case of a for loop). Upon encountering a break, execution
- goes to the code after the end of the named loop, nowhere near the
- colon.
-
- Looks pretty inconsistant, to me.
-
- Considering the state of most compiler diagnostics, I really wouldn't
- bother using *THAT* as a justification for *ANYTHING*. (except, perhaps,
- an *OSHA* standard for compiler diagnostics :-) )
-
- +C
-
-
- -------------------------------------------------------------
- Cory Kempf EnigamI, Inc.
- cory@enigami.mv.com ...!decvax!enigami!cory
- Annon: wi.5036@wizvax.methuen.ma.us
-
- "F' cryin' out loud, it's *your* life; shouldn't you at least examine
- your lifestyle values to see if they are really what *you* want."
- --Keith Lim
-