home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13327 < prev    next >
Encoding:
Text File  |  1992-09-07  |  2.5 KB  |  49 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mcsun!Germany.EU.net!ira.uka.de!slsvaat!us-es.sel.de!kanze
  3. From: kanze@us-es.sel.de (James Kanze)
  4. Subject: Re: GOTO, was: Tiny proposal for na
  5. Message-ID: <1992Aug31.170908.13389@us-es.sel.de>
  6. Sender: news@us-es.sel.de
  7. Organization: SEL-Alcatel LTS Dept. US/ES
  8. References: <714668024@thor> <6800007@tisdec.tis.tandy.com> <1992Aug26.130335.26725@hemlock.cray.com> <1992Aug26.194538.1598@spss.com> <rmartin.714931485@thor> <1992Aug27.181013.29933@spss.com> <rmartin.715102882@thor>
  9. Date: Mon, 31 Aug 92 17:09:08 GMT
  10. Lines: 37
  11.  
  12. In article <rmartin.715102882@thor>, rmartin@thor.Rational.COM (Bob Martin) writes:
  13. |> hosken@spss.com (Bill Hosken) writes:
  14.     [...]
  15. |> >A better rule would be "Be prepared to give a clear and convincing
  16. |> >argument that the code is correct". 
  17. |> 
  18. |> But what is "correct code"?  Code that works?  I can write code that
  19. |> works, but is unmaintainable.  If all we want to produce is "code that
  20. |> works", then the nightmares which have plagued us from the late
  21. |> sixties on are sure to continue.
  22.  
  23. Bob, don't you realize that Bill has just given the strongest argument yet
  24. in favor of what you've been saying.  The only "clear and convincing argument
  25. that the code is correct" must use logical proof of correctness concepts.
  26. These concepts, at least in the literature I've seen, *only* address the three
  27. basic forms of program flow: sequence, iteration and conditional.  In particular,
  28. to reason about program correctness, it is essential that each program block
  29. have one and only one point of entry and one and only one point of exit.
  30.  
  31. This means that you can use a goto, as long as it does exactly what a while,
  32. an if...else or a switch would do.  I can't see why you would want to in C,
  33. though, since it *does* have these structures.  (One of the best structured
  34. programs I ever saw was written in Fortran-66, and it was full of goto's.
  35. However, every one was used to mimic one of the above structures, none of
  36. which existed in the language.)
  37.  
  38. On the other hand, you *cannot* use break or continue, since these mimic a
  39. goto to somewhere you *do not* what to go to.  In the same way, how do you
  40. prove a function correct if it returns somewhere from the middle.
  41.  
  42. Apparently most of the responses have been in favor of using break.  Do I
  43. conclude that most programmers just don't care about having correct programs?
  44. --
  45. James Kanze                            GABI Software, Sarl.
  46. email: kanze@us-es.sel.de              8 rue du Faisan
  47.                                        67000 Strasbourg
  48.                                        France
  49.