[log in to unmask] wrote:
...
>I can think of NO example of prospective code design where GO TO could not
>be replaced in modern FORTRAN (with improved readability) by either:
>
>* CYCLE, LOOP or EXIT structures
>* An actual endless DO loop with EXIT (for reads of files of undefined
>number of lines)
>* An actual subroutine with appropriate entry and exit conditions
That's easy: error handling. The only solution that comes
close is the last one written as "call a subroutine and immediately
return after". But, that's semantically as general as GOTO (just
as easily made into spaghetti), and it's less legible. Yes, Knuth
showed that a GOTO can always be replaced by a procedure
call (to a suitably written procedure) followed immediately by
a return statement. He did _not_ conclude that was a better
way to write your code. In any case, if that's your solution
to avoiding GOTO, you haven't. You've just spelled GOTO
more verbosely. (Knuth also showed that a procedure call
followed by a return can always be replaced with a GOTO,
they are semantically identical.)
--
J. Giles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|