home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!decwrl!deccrl!news.crl.dec.com!rdg.dec.com!decvax.dec.com!enigami.mv.com!enigami.mv.com!cory
- From: cory@enigami.mv.com (Cory Kempf)
- Newsgroups: comp.lang.c++
- Subject: Re: named loops
- Message-ID: <0105011F.c23j5a@dragon.enigami.mv.com>
- Date: 26 Aug 92 15:33:10 GMT
- Reply-To: cory@enigami.mv.com
- Organization: EnigamI, Inc., Nashua, NH
- Lines: 58
- X-Mailer: uAccess - Macintosh Release: 1.6v1
-
-
- In article <BEVAN.92Aug23144650@tiger.cs.man.ac.uk> (comp.lang.c++), bevan@cs.man.ac.uk (Stephen J Bevan) writes:
- >In article <1992Aug22.171535.29638@taumet.com> steve@taumet.com (Steve Clamage) writes:
- > 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:
-
- Howabout:
-
- do { ... } while( ... );
- doLoop: { ... } if(...) goto doLoop;
-
- while ( ... ) { ... }
- whileLoop: if( ... ) { ... goto whileLoop; }
- anotherWhileLoop: if ( ... ) { ... }
- else goto endAnotherWhileLoop;
- goto anotherWhileLoop;
- endAnotherWhileLoop:
-
- etc.
-
- When it comes right down to it, almost EVERY language construct can
- be implimented via gotos and if statements. For that matter, data
- structures can be implimented via one dimensional arrays.
-
- The reason for NOT doing everything as a if/goto or as an array, is
- that the code becomes more self documenting.
-
- There are very few rules for what can be done with a goto. You can
- change the point of execution to almost anywhere.
-
- With a while loop, there are very strict rules: it is a loop that
- will cycle as long as the condition holds true.
-
- These rules are necessary to good programming. *YOU* may find them
- to be a pain, and arbitrary, but when you look at someone else's code,
- they can be the only thing that stands between being able to understand
- the code and losing your mind.
-
- In general, if there is a specific purpose to a goto, rules that define
- it's usage (such as exception handling in a pre-3.0 world), it is
- best to hide the goto inside of a structure that provides a rigid
- set of rules for it use. It make the code much easier to understand.
-
- +C
-
-
-
- -------------------------------------------------------------
- Cory Kempf EnigamI, Inc.
- cory@enigami.mv.com ...!decvax!enigami!cory
- Annon: wi.5036@wizvax.methuen.ma.us
-
- "F' cryin' out loud, it's *your* life; shouldn't you at least examine
- your lifestyle values to see if they are really what *you* want."
- --Keith Lim
-