home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mcsun!Germany.EU.net!ira.uka.de!slsvaat!us-es.sel.de!kanze
- From: kanze@us-es.sel.de (James Kanze)
- Subject: Re: GOTO, was: Tiny proposal for na
- Message-ID: <1992Aug31.170908.13389@us-es.sel.de>
- Sender: news@us-es.sel.de
- Organization: SEL-Alcatel LTS Dept. US/ES
- 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>
- Date: Mon, 31 Aug 92 17:09:08 GMT
- Lines: 37
-
- In article <rmartin.715102882@thor>, rmartin@thor.Rational.COM (Bob Martin) writes:
- |> hosken@spss.com (Bill Hosken) writes:
- [...]
- |> >A better rule would be "Be prepared to give a clear and convincing
- |> >argument that the code is correct".
- |>
- |> But what is "correct code"? Code that works? I can write code that
- |> works, but is unmaintainable. If all we want to produce is "code that
- |> works", then the nightmares which have plagued us from the late
- |> sixties on are sure to continue.
-
- Bob, don't you realize that Bill has just given the strongest argument yet
- in favor of what you've been saying. The only "clear and convincing argument
- that the code is correct" must use logical proof of correctness concepts.
- These concepts, at least in the literature I've seen, *only* address the three
- basic forms of program flow: sequence, iteration and conditional. In particular,
- to reason about program correctness, it is essential that each program block
- have one and only one point of entry and one and only one point of exit.
-
- This means that you can use a goto, as long as it does exactly what a while,
- an if...else or a switch would do. I can't see why you would want to in C,
- though, since it *does* have these structures. (One of the best structured
- programs I ever saw was written in Fortran-66, and it was full of goto's.
- However, every one was used to mimic one of the above structures, none of
- which existed in the language.)
-
- On the other hand, you *cannot* use break or continue, since these mimic a
- goto to somewhere you *do not* what to go to. In the same way, how do you
- prove a function correct if it returns somewhere from the middle.
-
- Apparently most of the responses have been in favor of using break. Do I
- conclude that most programmers just don't care about having correct programs?
- --
- James Kanze GABI Software, Sarl.
- email: kanze@us-es.sel.de 8 rue du Faisan
- 67000 Strasbourg
- France
-