home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12699 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  1.5 KB

  1. Path: sparky!uunet!cs.utexas.edu!swrinde!mips!darwin.sura.net!ukma!vlsi!starbase.spd.louisville.edu!aldavi01
  2. From: aldavi01@starbase.spd.louisville.edu (Arlie Davis)
  3. Newsgroups: comp.lang.c++
  4. Subject: Tiny proposal for named loops.
  5. Message-ID: <aldavi01.714376080@starbase.spd.louisville.edu>
  6. Date: 21 Aug 92 05:48:00 GMT
  7. Sender: news@vlsi.louisville.edu (Network News System)
  8. Organization: University of Louisville
  9. Lines: 28
  10. Nntp-Posting-Host: starbase.spd.louisville.edu
  11.  
  12. Since the language is still open to improvements, even those which relate to
  13. the more C-oriented personality of C++, I'd like to suggest the addition
  14. of named loops.  The syntax would not break any existing code at all.
  15. An identifier would be placed just after the "for", "while", "do", or even
  16. "if" keyword.  This keyword could be used just after "break" or "continue",
  17. to specify exactly which loop to break or continue.
  18.  
  19. Example:
  20.  
  21. for main_loop (...)
  22.   // ...
  23.   for inner_loop (...)
  24.     // ... complex mess of loops ...
  25.           break main_loop;       // somewhere deep inside the loops
  26.     // ...
  27.           continue inner_loop;   // similarly, deep inside loops
  28.  
  29.  
  30. This would eliminate the need for some state variables used with switches,
  31. which would make code more readable, and more block-oriented.
  32.  
  33. Yes, it's a structured goto.  But so are break and continue in the first place
  34. -- this is an improvement of them.
  35.  
  36. Any comments in email, please.
  37.  
  38. -- 
  39. lrwx------   1 aldavi01 emacsstu       9 Jun  6 12:43 .signature -> /dev/null
  40.