home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mcsun!Germany.EU.net!unidus.rz.uni-duesseldorf.de!lannert.rz.uni-duesseldorf.de!TSOS
- From: TSOS@uni-duesseldorf.de (Detlef Lannert)
- Subject: Re: Tiny proposal for named loops.
- Message-ID: <TSOS.61.714395736@uni-duesseldorf.de>
- Sender: news@unidus.rz.uni-duesseldorf.de
- Organization: Universitaetsrechenzentrum, Heinrich-Heine-Universitaet, Duesseldorf
- References: <aldavi01.714376080@starbase.spd.louisville.edu>
- Date: Fri, 21 Aug 1992 11:15:36 GMT
- Lines: 58
-
- In article <aldavi01.714376080@starbase.spd.louisville.edu> 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. The syntax would not break any existing code at all.
- >An identifier would be placed just after the "for", "while", "do", or even
- >"if" keyword. This keyword could be used just after "break" or "continue",
- >to specify exactly which loop to break or continue.
- >
- >Example: [deleted for bandwidth's sake]
- >
- >This would eliminate the need for some state variables used with switches,
- >which would make code more readable, and more block-oriented.
-
- I like your idea. It could certainly make C[++] code safer
- and more legible. There shouldn't be any syntactical problem
- with
-
- if [<id>] (<expression>) <statement>
- switch [<id>] (<expression>) <statement>
- while [<id>] (<expression>) <statement>
- do <statement> while [<id>] (<expression>) ;
- for [<id>] (...;...;...) <statement>
-
- A "break <id>;" statement would be useful for the "switch"
- construct as well as for "while", "do...while", and "for",
- as would the "continue <id>;" for the repetitive statements.
-
- For the "if", however, there would be no use in assigning
- any identification because it does not constitute any blocks
- by itself and "continue" or "break" is not applicable.
-
- Talking about blocks: Have there been any discussions about
- a possible assignment of identifications to blocks? Something
- like
-
- {<block-id>
- ...
- <block-id>}
-
- instead of just
-
- {
- ...
- }
-
- could improve the legibility of C[++] programs and help
- localize errors. (A compiler error message should be
- generated whenever the block-id of the closing } doesn't
- match that of the opening {.) Of course this feature would
- have to be optional.
-
- I apologize if this suggestion has been discussed before;
- otherwise I'd like to hear your comments (and suggestions
- with regard to a possible syntax).
- --
- Detlef Lannert DC3EK E-Mail: tsos@rz.uni-duesseldorf.de
- "Ab morgen wird gearbeitet."
-