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