From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,14f7200925acb579 X-Google-Attributes: gid103376,public From: dvdeug@x8b4e53cd.dhcp.okstate.edu (David Starner) Subject: Re: No Go To's Forever! Date: 2000/03/21 Message-ID: <8b8vho$7pu1@news.cis.okstate.edu>#1/1 X-Deja-AN: 600638179 Content-Transfer-Encoding: 8bit References: <38D7B41D.B3494C6A@lmco.com> <38D7B83B.27DC06C8@earthlink.net> Content-Type: text/plain; charset=iso-8859-1 Organization: Oklahoma State University Mime-Version: 1.0 User-Agent: slrn/0.9.6.2 (Linux) Reply-To: dstarner98@aasaa.ofe.org Newsgroups: comp.lang.ada Date: 2000-03-21T00:00:00+00:00 List-Id: On Wed, 22 Mar 2000 00:00:10 +0100, Tim Gahnstr�m 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