home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 12947 < prev    next >
Encoding:
Internet Message Format  |  1992-08-26  |  2.5 KB

  1. Path: sparky!uunet!usc!cs.utexas.edu!devnull!rgp
  2. From: rgp@mpd.tandem.com (Ramon Pantin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: GOTO, was: Tiny proposal for na
  5. Message-ID: <2318@devnull.mpd.tandem.com>
  6. Date: 27 Aug 92 03:36:40 GMT
  7. References: <714668024@thor> <6800007@tisdec.tis.tandy.com> <rmartin.714863091@thor>
  8. Sender: news@devnull.mpd.tandem.com
  9. Organization: Tandem Computers, Micro-Products Division
  10. Lines: 44
  11.  
  12. In article <rmartin.714863091@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
  13. >kevinl@tisdec.tis.tandy.com writes:
  14. >
  15. >|    I have to paritally disagree.  Everytime you add a flag variable,
  16. >|you are doubling the number of states for your program.  The more states,
  17. >|the more possible paths, and the more paths, the more possible unforseen
  18. >|errors (if the paths are not anticipated and tested--something that is
  19. >|very hard to do).
  20. >
  21. >No, the influence of state variables which control loops is limitted
  22. >to the loop condition, and possibly to tests at the completion of the
  23. >loop.  Thus, the "doubling" does not occur.
  24.  
  25. It is well known that to rewrite code that uses breaks, continues,
  26. mid-function returns and gotos (in the most general case) you have to
  27. either:
  28.     - Add state variables to the head of loops and additional tests
  29.       of these variables within the bodies of the loops; or
  30.     - State variables only tested at the head of the loops and
  31.       code duplication.
  32.  
  33. So you either duplicate code (as you did in the example a couple of
  34. postings ago) or you have to add additional tests within the loops
  35. (which I showed in my "structured" version of the original C example).
  36.  
  37. So your wins are:
  38.     - Code duplication, difficult to maintain (in one of your
  39.       previous posts you din't even seem to agree that code
  40.       duplication was difficult to maintain!); or
  41.     - A complexity explosion in your code (number of code paths +
  42.       tests and sets of state variables).
  43.  
  44. From my informal counts in this thread it seems that most people are
  45. perfectly happy with break, continue and mid-function returns.  Some
  46. group of people avoid gotos as a rule of thumb but wouldn't mind using
  47. them if required, some of these have not used a goto in the last 10 years.
  48. A smaller group (only you?) avoid all of these contructs completely.
  49.  
  50. In any case Bob, nobody is suddenly going to have a religious experience
  51. right here and convert themselves to the other camp, so if you don't see
  52. more followups on this subject it is not because of that, but because this
  53. subject has already been beaten to death and at least I've got tired of it.
  54.  
  55. Ramon Pantin
  56.