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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!uunet.ca!geac!alias!news
  3. From: Reid Ellis <rae@Alias.com>
  4. Subject: Re: named loops
  5. Message-ID: <1992Aug21.143653.10805@alias.com>
  6. Sender: news@alias.com (News Owner)
  7. Organization: Alias Research, Inc., Toronto ON Canada
  8. References: <aldavi01.714376080@starbase.spd.louisville.edu>
  9. Date: Fri, 21 Aug 1992 14:36:53 GMT
  10. Lines: 34
  11.  
  12. Arlie Davis <aldavi01@starbase.spd.louisville.edu> writes:
  13. |for main_loop (...)
  14. |  // ...
  15. |  for inner_loop (...)
  16. |    // ... complex mess of loops ...
  17. |          break main_loop;       // somewhere deep inside the loops
  18. |    // ...
  19. |          continue inner_loop;   // similarly, deep inside loops
  20.  
  21. How about an int argument to "break", as supported in many scripting
  22. languages?  Add a similar argument to "continue" while we're at it.
  23. Then you can do things like this:
  24.  
  25. for(...) { // loop outer
  26.     for(...) { // loop middle
  27.         for(...) { // loop inner
  28.  
  29.             break; // breaks out of inner
  30.  
  31.             break 2; // breaks out of middle
  32.  
  33.             continue 2; // continues middle
  34.         } // loop 3
  35.     } // loop 2
  36. } // loop 1
  37.  
  38. An argument of zero or one would cause the current, default behaviour.
  39. Just a thought...
  40.  
  41.                         Reid
  42. --
  43. Reid Ellis                                            
  44. rae@utcs.utoronto.ca        ||           rae@Alias.com
  45. CDA0610@applelink.apple.com ||  +1 416 362 9181 [work]
  46.