Hi all
In response to my recent outburst, that great jokester Van Snyder sent me
2,715 lines of legacy code in a specialist field; and we have the following
from Mr Giles.
I intend to follow my own recent advice: I know when to quit.
I would suggest that the test of good code is NOT ONLY that it works now and
for the one person who understands it.
In that respect, I have no problem with being verbose....speed is another
matter.
BTW, I have the occasional GO TO statements in code of 'mine' - with comment
lines to indicate structural (logical) flow.
Best regards to all
Gaz
-----Original Message-----
From: James Giles [mailto:[log in to unmask]]
Sent: Thursday, 31 August 2000 10:51
To: [log in to unmask]
Subject: Re: GO TO
[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
************************************************************************
The information in this e-mail together with any attachments is
intended only for the person or entity to which it is addressed
and may contain confidential and/or privileged material.
Any form of review, disclosure, modification, distribution
and/or publication of this e-mail message is prohibited.
If you have received this message in error, you are asked to
inform the sender as quickly as possible and delete this message
and any copies of this message from your computer and/or your
computer system network.
************************************************************************
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|