home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!igor!frito!rw
- From: rw@frito.Rational.COM (Bob Weissman)
- Newsgroups: comp.lang.c++
- Subject: Re: Tiny proposal for named loops.
- Message-ID: <rw.714437749@frito>
- Date: 21 Aug 92 22:55:49 GMT
- References: <aldavi01.714376080@starbase.spd.louisville.edu> <rmartin.714435942@dirac>
- Sender: news@Rational.COM
- Lines: 36
-
- |aldavi01@starbase.spd.louisville.edu (Arlie Davis) writes:
- ||Since the language is still open to improvements, even those which relate to
- ||the more C-oriented personality of C++, I'd like to suggest the addition
- ||of named loops.
- ||for main_loop (...)
- || // ...
- || for inner_loop (...)
- || // ... complex mess of loops ...
- || break main_loop; // somewhere deep inside the loops
- || // ...
- || continue inner_loop; // similarly, deep inside loops
-
- rmartin@dirac.Rational.COM (Bob Martin) responds:
-
- |IMHO breaks and continues should be avoided, not improved. As you
- |say, they are a form of goto. Don't use them, except in case
- |statements where you must :-( use break.
- |
- |State variables are preferable to breaks and continues. Judicious use
- |of them allows all loops and blocks to be exited at the same place.
- |This benefit outweighs the disadvantage of using a flag.
-
- I disagree. I generally prefer a multi-level break to cluttering
- my code with extraneous state variables.
-
- Use of named loops as in the original proposal is (IMHO as always)
- clearer in intent than having a slew of flags.
-
- On the other hand, I'm not sure C++ needs *any* new features. It's
- starting to resemble PL/I... :-)
-
- --
- -- Bob Weissman
- -- Internet: rw@rational.com
- -- UUCP: uunet!igor!rw
- --
-