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

  1. Path: sparky!uunet!igor!frito!rw
  2. From: rw@frito.Rational.COM (Bob Weissman)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Tiny proposal for named loops.
  5. Message-ID: <rw.714437749@frito>
  6. Date: 21 Aug 92 22:55:49 GMT
  7. References: <aldavi01.714376080@starbase.spd.louisville.edu> <rmartin.714435942@dirac>
  8. Sender: news@Rational.COM
  9. Lines: 36
  10.  
  11. |aldavi01@starbase.spd.louisville.edu (Arlie Davis) writes:
  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.
  15. ||for main_loop (...)
  16. ||  // ...
  17. ||  for inner_loop (...)
  18. ||    // ... complex mess of loops ...
  19. ||          break main_loop;       // somewhere deep inside the loops
  20. ||    // ...
  21. ||          continue inner_loop;   // similarly, deep inside loops
  22.  
  23. rmartin@dirac.Rational.COM (Bob Martin) responds:
  24.  
  25. |IMHO breaks and continues should be avoided, not improved.  As you
  26. |say, they are a form of goto.  Don't use them, except in case
  27. |statements where you must :-( use break.
  28. |
  29. |State variables are preferable to breaks and continues.  Judicious use
  30. |of them allows all loops and blocks to be exited at the same place.
  31. |This benefit outweighs the disadvantage of using a flag.
  32.  
  33. I disagree.  I generally prefer a multi-level break to cluttering
  34. my code with extraneous state variables.
  35.  
  36. Use of named loops as in the original proposal is (IMHO as always)
  37. clearer in intent than having a slew of flags.
  38.  
  39. On the other hand, I'm not sure C++ needs *any* new features.  It's
  40. starting to resemble PL/I... :-)
  41.  
  42. --
  43. -- Bob Weissman
  44. -- Internet: rw@rational.com
  45. -- UUCP:     uunet!igor!rw
  46. --
  47.