home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12765 < prev    next >
Encoding:
Text File  |  1992-08-22  |  1.6 KB  |  39 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: named loops
  5. Message-ID: <1992Aug22.171535.29638@taumet.com>
  6. Organization: TauMetric Corporation
  7. References: <aldavi01.714376080@starbase.spd.louisville.edu> <1992Aug21.143653.10805@alias.com>
  8. Date: Sat, 22 Aug 1992 17:15:35 GMT
  9. Lines: 28
  10.  
  11. Reid Ellis <rae@Alias.com> writes:
  12.  
  13. >How about an int argument to "break", as supported in many scripting
  14. >languages?  Add a similar argument to "continue" while we're at it.
  15.  
  16. This gets proposed every few months.  It makes a maintenance nightmare,
  17. since changes in nesting change the semantics of the break with no
  18. warning.  If you are very lucky, the break level will become illegal
  19. and the compiler will complain.  More likely the wrong loop will be
  20. exited -- a bug which may be hard to find, or which might not even
  21. show up in testing.
  22.  
  23. A named loop would not have this problem, assuming loop names are like
  24. statement labels.  I also agree that named loops are more structured
  25. than using ordinary labels and gotos.  Nevertheless, I don't believe
  26. there is any chance that named loops will be added to the language.
  27. The main reason, as I see it, is that it adds no functionality and no
  28. notational convenience to the language.  Compare:
  29.  
  30.     while loop1 (...) { ... break loop1;   ... }
  31.     while       (...) { ... goto endloop1; ... } endloop1:
  32.  
  33.     while loop2 (...) { ... continue loop2; ...         }
  34.     while       (...) { ... goto loop2;     ... loop2:; }
  35. -- 
  36.  
  37. Steve Clamage, TauMetric Corp, steve@taumet.com
  38. Vice Chair, ANSI C++ Committee, X3J16
  39.