home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 12912 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  2.8 KB

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