From: dvdeug@x8b4e53cd.dhcp.okstate.edu (David Starner)
Subject: Re: No Go To's Forever!
Date: 2000/03/21
Date: 2000-03-21T00:00:00+00:00 [thread overview]
Message-ID: <8b8vho$7pu1@news.cis.okstate.edu> (raw)
In-Reply-To: Pine.SOL.4.21.0003212347450.15450-100000@fraggel81.mdstud.chalmers.se
On Wed, 22 Mar 2000 00:00:10 +0100, Tim Gahnstr�m <md9tim@mdstud.chalmers.se> wrote:
>I notice that alot of people really hate gotos...
>But why is it sooo bad can someone tell me that???
This is some real code (from Axelrod's simulation of the
Prisoner's Dillema). This, mind you, is opening up the
file and basically randomly grabing a function - there
is much, much worse in that file alone.
FUNCTION K58R(J,M,K,L,R, JA)
C BY GLEN ROWSAM
C TYPED BY JM
k58r=ja ! Added 7/27/93 to report own old value
IF (M .GT. 1) GOTO 99
KAM = 0
NPHA = 0
99 IF (KAM .GT. 6) GOTO 87
IF (NPHA .GE. 1) GOTO 89
IF ((M / 18) * 18 .EQ. M .AND. KAM .GT. 2) KAM = KAM - 1
IF ((M / 6) * 6 .NE. M) GOTO 88
IF (K .LT. M) GOTO 10
IF (K * 10 .LT. M * 15) GOTO 11
IF (K .LT. M * 2) GOTO 12
IF (K * 10 .LT. M * 25) GOTO 13
GOTO 88
10 KAM = KAM + 2
11 KAM = KAM + 1
12 KAM = KAM + 1
13 KAM = KAM + 1
NPHA = 2
GOTO 87
89 NPHA = NPHA - 1
IF (NPHA .EQ. 0) GOTO 87
88 K58R = 0
GOTO 86
87 K58R = 1
86 RETURN
END
Much of the blame for goto hating must go to FORTRAN <= 77, which
requires goto's for common stuff and provides only numeric labels.
>I assume this is a typical example of bad goto use
At first glance I don't think it works, and it would be
a little easier to read if you used control structures
instead of gotos, but it's not a typical example.
>Is goto statments particular slow?
No, but a modern compiler can frequently handle the other
control structures faster (more information to optimize with.)
Anyway, the arguments against gotos has always been that they're
hard to read, and that readibility should come before optimization.
--
David Starner - dstarner98@aasaa.ofe.org
Only a nerd would worry about wrong parentheses with
square brackets. But that's what mathematicians are.
-- Dr. Burchard, math professor at OSU
next prev parent reply other threads:[~2000-03-21 0:00 UTC|newest]
Thread overview: 105+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-21 0:00 No Go To's Forever! Bill Dale
2000-03-21 0:00 ` David Starner
2000-03-21 0:00 ` Bill Dale
2000-03-22 0:00 ` Robert Dewar
2000-03-22 0:00 ` Robert Dewar
2000-03-22 0:00 ` Paul Graham
2000-03-22 0:00 ` Robert Dewar
2000-03-22 0:00 ` Michael P. Walsh
2000-03-22 0:00 ` Charles Hixson
2000-04-06 0:00 ` Wes Groleau
2000-04-07 0:00 ` Charles Hixson
2000-03-22 0:00 ` Brian Rogoff
2000-03-22 0:00 ` Ted Dennison
2000-03-22 0:00 ` Michael P. Walsh
2000-03-23 0:00 ` Robert Dewar
2000-03-22 0:00 ` Paul Graham
2000-03-23 0:00 ` Robert Dewar
2000-03-23 0:00 ` Ted Dennison
2000-03-23 0:00 ` Larry Kilgallen
2000-03-23 0:00 ` Robert Dewar
2000-03-23 0:00 ` Paul Graham
2000-03-23 0:00 ` Robert Dewar
2000-03-22 0:00 ` Robert A Duff
2000-03-22 0:00 ` Roger Barnett
2000-03-22 0:00 ` Charles Hixson
2000-03-22 0:00 ` Robert Dewar
2000-03-21 0:00 ` Charles Hixson
2000-03-21 0:00 ` Robert Dewar
2000-03-21 0:00 ` Michael P. Walsh
2000-03-21 0:00 ` Andrew Berg
2000-03-22 0:00 ` Wes Groleau
2000-03-22 0:00 ` No Go To's Forever! (I'm sorry I spoke...) dis90072
2000-03-23 0:00 ` tmoran
2000-03-23 0:00 ` Larry Kilgallen
2000-03-22 0:00 ` No Go To's Forever! Ken Garlington
2000-03-22 0:00 ` Marin D. Condic
2000-03-22 0:00 ` Roger Barnett
2000-03-22 0:00 ` Larry Kilgallen
2000-03-23 0:00 ` Robert Dewar
2000-03-23 0:00 ` Keith Thompson
2000-03-24 0:00 ` Marin D. Condic
2000-03-24 0:00 ` Ted Dennison
2000-03-27 0:00 ` Keith Thompson
2000-03-28 0:00 ` Come From Forever! (was: No Go To's Forever!) Ted Dennison
2000-03-29 0:00 ` Keith Thompson
2000-03-25 0:00 ` No Go To's Forever! Richard D Riehle
2000-03-21 0:00 ` Gautier
2000-03-22 0:00 ` Tim Gahnström
2000-03-21 0:00 ` David Starner [this message]
2000-03-22 0:00 ` tmoran
2000-03-22 0:00 ` Robert Dewar
2000-03-22 0:00 ` tmoran
2000-03-23 0:00 ` Robert Dewar
2000-03-23 0:00 ` tmoran
2000-03-23 0:00 ` Robert Dewar
2000-03-23 0:00 ` Jeff Carter
2000-03-24 0:00 ` Robert Dewar
2000-03-23 0:00 ` tmoran
2000-03-24 0:00 ` Robert Dewar
2000-03-24 0:00 ` Robert Dewar
2000-04-16 0:00 ` Kenneth Almquist
2000-04-17 0:00 ` Robert Dewar
2000-04-18 0:00 ` Dale Stanbrough
2000-04-18 0:00 ` David Starner
2000-04-18 0:00 ` Robert Dewar
2000-04-17 0:00 ` Robert Dewar
2000-03-29 0:00 ` Martin Dowie
2000-03-29 0:00 ` Florian Weimer
2000-03-29 0:00 ` Robert Dewar
2000-03-30 0:00 ` Robert A Duff
2000-04-01 0:00 ` Robert Dewar
2000-04-01 0:00 ` Robert A Duff
2000-04-02 0:00 ` Robert Dewar
2000-04-21 0:00 ` Florian Weimer
2000-04-21 0:00 ` Robert Dewar
2000-03-29 0:00 ` Robert Dewar
2000-03-29 0:00 ` Robert Dewar
2000-03-24 0:00 ` tmoran
2000-03-22 0:00 ` Robert Dewar
2000-03-22 0:00 ` Ken Garlington
2000-03-21 0:00 ` Keith Thompson
2000-03-22 0:00 ` Robert Dewar
2000-03-23 0:00 ` Ken Garlington
2000-03-22 0:00 ` Robert Dewar
2000-03-23 0:00 ` Tim Gahnstr�m
2000-03-22 0:00 ` Pascal Obry
2000-03-22 0:00 ` Marin D. Condic
2000-03-22 0:00 ` Robert Dewar
2000-03-22 0:00 ` Robert Dewar
2000-03-22 0:00 ` Robert Dewar
2000-03-22 0:00 ` Jon S Anthony
2000-03-22 0:00 ` Roger Barnett
2000-03-23 0:00 ` Robert Dewar
2000-03-23 0:00 ` Roger Barnett
2000-03-24 0:00 ` Robert Dewar
2000-03-23 0:00 ` Robert Dewar
2000-03-22 0:00 ` Jon S Anthony
2000-03-23 0:00 ` Chris Morgan
2000-03-22 0:00 ` Richard D Riehle
2000-03-23 0:00 ` Jeff Carter
2000-03-23 0:00 ` Robert Dewar
2000-03-23 0:00 ` Michael P. Walsh
2000-03-23 0:00 ` Brian Rogoff
[not found] ` <01bf9436$9c054880$2c5101be@bthomas4663>
2000-03-23 0:00 ` Robert Dewar
2000-03-23 0:00 ` Ken Garlington
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox