home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!cs.utexas.edu!csc.ti.com!tilde.csc.ti.com!mksol!mccall
- From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
- Subject: Re: GOTO, was: Tiny proposal for named loops.
- Message-ID: <1992Sep9.210632.25891@mksol.dseg.ti.com>
- Organization: Texas Instruments Inc
- References: <2318@devnull.mpd.tandem.com> <rmartin.715001372@thor> <4192@papaya.bbn.com> <1992Sep2.131733.20676@terminator.cc.umich.edu> <r <KERS.92Sep4082931@cdollin.hpl.hp.com> <rmartin.715618743@thor>
- Date: Wed, 9 Sep 1992 21:06:32 GMT
- Lines: 69
-
- In <rmartin.715618743@thor> rmartin@thor.Rational.COM (Bob Martin) writes:
-
- >kers@hplb.hpl.hp.com (Chris Dollin) writes:
-
- >|In what sense do you claim that ``these rules'' (by which I understand you to
- >|mean the usual rules of structured programming) have been ``proven'' to be
- >|``workable''?
-
- >Only that it has been proven that gotos are unecessary. That any
- >algorithm can be written in terms of sequence, selection and
- >repetition.
-
- And I will reiterate that the fact that something has been proven to
- be possible does NOT necessarily mean it is always a good idea. As I
- said before, one can also implement any algorithm in terms of 'goto'
- and a conditional jump.
-
- >Yes, so lets forget the psychological part and focus on the
- >mathematical part. Constructiong your algorithms based on SP causes
- >you to separate paths that you might otherwise combine (with gotos).
- >This separation decouples the paths from each other, so that changes
- >made in one path do not affect the other paths.
-
- The fact that goto CAN be abused is hardly a good rationale for saying
- that it is always bad, either.
-
- >We don't use SP because it makes the code "prettier" or
- >psychologically more gratifying. We use it because it separates the
- >code fragments and reduces coupling. This makes the code easier to
- >maintain.
-
- Sorry, but that's hardly the reason. Where is the 'coupling' or the
- difficulty in maintenance when goto is used for things like error
- handling or error returns? Frankly, I find those Pascaloid disasters
- of code containing an 8-deep nesting of 'if' and flags to be a lot
- less readable and a lot less maintainable than code that makes
- judicicious use of what you would categorize as 'bad' constructs. I
- don't think I'm alone in this (or even in the minority, if you want
- the truth).
-
- >|There's a
- >|lot of empirical evidence to suggest that traditional SP ``works'', ie, that
- >|for very many programming problems, they are an effective solution. [The
- >|evidence is the large number of programs written effectively in that style.]
- >|But there's also evidence that they're not *enough* -- that other control
- >|structures are needed for clarity -- consider
-
- >| * procedures
- >| * FOR-loops (of various kinds)
- >| * N+1/2 times loops
- >| * Scheme-style use of tail-call
- >| * Co-routines
- >| * Higher-order functions
-
- >|for example.
-
- >Agreed.
- >The last thing I advocate is a reduction of all code to one linear
- >stream of sequence, selection and repetition.
-
- But that is exactly your rataionale for why structured programming
- 'works'; that it is possible to implement anything using sequence,
- selection, and repetition.
-
- --
- "Insisting on perfect safety is for people who don't have the balls to live
- in the real world." -- Mary Shafer, NASA Ames Dryden
- ------------------------------------------------------------------------------
- Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
-