home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13338 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  4.0 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: <2388@devnull.mpd.tandem.com>
  6. Date: 5 Sep 92 17:31:35 GMT
  7. References: <1992Aug27.181013.29933@spss.com> <rmartin.715102882@thor> <1992Aug31.170908.13389@us-es.sel.de>
  8. Sender: news@devnull.mpd.tandem.com
  9. Organization: Tandem Computers, Micro-Products Division
  10. Lines: 73
  11.  
  12. In article <1992Aug31.170908.13389@us-es.sel.de> kanze@us-es.sel.de (James Kanze) writes:
  13.  
  14. >... The only "clear and convincing argument
  15. >that the code is correct" must use logical proof of correctness concepts.
  16. >These concepts, at least in the literature I've seen, *only* address the three
  17. >basic forms of program flow: sequence, iteration and conditional.  In particular,
  18. >to reason about program correctness, it is essential that each program block
  19. >have one and only one point of entry and one and only one point of exit.
  20.  
  21. Mathematical reasoning tends to be "constructive" in nature.  If all non
  22. structured programs (by the Structured Programming definition) can be
  23. mechanically converted to structured programs, then it is not necesary
  24. to investigate methods for proving non structured programs correct,
  25. correctnes of non-structured programs can be proven by transforming them
  26. into structured programs and then proving those correct.
  27.  
  28. The fact that the literature shows research in the areas of proving program
  29. correctness doesn't preclude YOU from reasoning in any way you want about
  30. your program's correctness.  BTW, the research that I've seen is directed
  31. at mechanically proving things correct, not as thinking aids for programmers.
  32.  
  33. It seems that for some programmers (like me) it is harder to think about
  34. correctness when we see pascaloid code with lots of state variables, lots
  35. of places where they are tested and set, lots of indentation as the result
  36. of not using breaks, continues or returns.  Some other programmers (like
  37. you and Mr. Martin) prefer to reason about programs that simply avoid all
  38. the non-SP contructs and replace them with state variables, duplicated
  39. code and lots of indentation.
  40.  
  41. >...
  42.  
  43. >On the other hand, you *cannot* use break or continue, since these mimic a
  44. >goto to somewhere you *do not* what to go to.  In the same way, how do you
  45. >prove a function correct if it returns somewhere from the middle.
  46.  
  47. Very simple, mechanically transform it to SP and then mechanically prove 
  48. it correct.  How else?  Just run:
  49.     $ nonsp2sp nonsp.c | prove - nonsp.specs 
  50.     $ echo $?
  51.     0
  52.     $
  53.  
  54. >Apparently most of the responses have been in favor of using break.  Do I
  55. >conclude that most programmers just don't care about having correct programs?
  56.  
  57. Talking about logic, huh?  You can't conclude that!  (Can't use "leaps of
  58. faith" in logic constructions).
  59.  
  60. There is a big difference between "having correct programs" and being
  61. able to (or even wanting to) prove those programs correct!
  62. Your statement indicates that programs that use "break" cannot be correct.
  63. Or to put it your way, the programmers that use break cannot have correct
  64. programs.
  65.  
  66. A program can be correct even if nobody can prove it correct.  The truth
  67. value of a logical proposition doesn't change if individuals that read it
  68. can't determine its truth value (i.e. if they can't prove it or show a
  69. counter example).  The world never stopped being quasi-spherical even if
  70. nobody could prove it, observe it, or believe it.
  71.  
  72. It is also important to note that most programmers are interested in
  73. writting correct programs than being able to prove them correct.
  74.  
  75. When was the last time that YOU proved one of your "real world" programs
  76. (at least 10000+ lines) correct?  How long did it take you?  Assuming that
  77. you have ever done this, how did you felt when, after having proving it
  78. correct, you found your first bug?  How did you prove that the prove was
  79. correct (an so on) ?  How did you maintain the prove when you had to
  80. maintain the program when a set of features was added?
  81.  
  82. Think and program as it better fits your brain.
  83.  
  84. Ramon Pantin
  85.