The D Programming Language: cases (fallthrough)
Richard Harter
g-rh at cca.CCA.COM
Mon Mar 7 09:31:13 AEST 1988
In article <12159 at brl-adm.ARPA> PEPRBV%CFAAMP.BITNET at husc6.harvard.EDU (Bob Babcock) writes:
>I don't understand. First you give a perfectly reasonable example of
>the use of goto (which would be awkward to code otherwise), and then
>you propose eliminating goto from the language because you don't use
>it very often. One of the reasons I like programming in C rather than
>(pre-77) Fortran is that you have the flow control constructs
>necessary to eliminate abusive use of goto's, but you still have
>goto available for the occasional place where it best expresses
>what you want to do.
My apologies for muddying the waters. Yes, there are rare occasions where
a goto lets you build by hand a construct that is not available in the
language. Most of these instances reflect deficiencies in the language.
In the example I cited the deficiencies are:
(a) C has two escape statements, break and return. 'return' escapes
from the outermost containing block (the function). 'break' is a little
ambiguous. By analogy one would expect it to escape from the innermost
containing block. Actually, of course, it escapes from loops and switch
control structures. C would be improved if it had better escape constructs.
(b) C has no provision for epilogs -- an epilog being a block of code
executed after an escape. I don't quite see how one puts epilogs in C
in any natural fashion.
The question I was raising was whether the rare instances where a goto
is actually useful warrant retaining it in the language. You and I, of
course, will use them wisely and only when warranted. But I could do
without them in C. The times that I would have to get around not having
them available are few compared to other awkwardnesses in the language.
Incidentally, the objection I have to older Fortran is not so much
the abusive use of goto's (a complaint I will leave to theoreticians)
but is their awkwardness -- expressing any kind of complicated logic
in Fortran 66 is rather like solving a chinese box puzzle.
--
In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die.
Richard Harter, SMDS Inc.
More information about the Comp.lang.c
mailing list