Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end From: glen herrmannsfeldt Newsgroups: comp.compilers Subject: Re: How to type braces for computed gotos Date: Mon, 21 Jul 2014 16:19:44 +0000 (UTC) Organization: Aioe.org NNTP Server Lines: 48 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <14-07-050@comp.compilers> References: <14-05-013@comp.compilers> <14-07-033@comp.compilers> <14-07-048@comp.compilers> NNTP-Posting-Host: news.iecc.com X-Trace: miucha.iecc.com 1405963376 57994 2001:470:1f07:1126:0:676f:7373:6970 (21 Jul 2014 17:22:56 GMT) X-Complaints-To: abuse@iecc.com NNTP-Posting-Date: Mon, 21 Jul 2014 17:22:56 +0000 (UTC) Keywords: Fortran, history Posted-Date: 21 Jul 2014 13:22:56 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com X-Received-Bytes: 3077 X-Received-Body-CRC: 904147994 Xref: csiph.com comp.compilers:1340 Anton Ertl wrote: (snip) > I guess this compiler implements the labels-as-values extension of GNU > C (aka "computed goto", but see the Fortran note below). (snip) > BTW, in Fortran this feature is called "assigned goto", and it uses > integer variables (i.e., not a special type, either) for storing the > labels (and therefore needs a separate syntax "assign 50 to l" instead > of just writing "l=50"). The ASSIGN statement and assigned GOTO trace back to the original Fortran compiler, now often called Fortran I. The SUBROUTINE, CALL, and FUNCTION statements came in with Fortran II. The only subroutine call mechanism available with the Fortran I system was to ASSIGN a statement label to return to to some variable, GOTO to the subroutine, and then at the end of the subroutine GOTO back. While the computed-GOTO was also available, I suspect that the efficiency gain (both speed and code size) on a 36 bit word vacuum tube computer available, I believe, with between 8K and 32K words of magnetic core memory. But ASSIGN and the corresponding GOTO were removed from the standard as of Fortran 95. The suggested replacement is the comptued GOTO. Presumably someone should be able to write a program to automate the conversion. > Fortran also has a feature called "computed goto", but that is > closer to a C switch than a GNU C "goto *". The computed GOTO also traces back to Fortran I. It allows one to select a statement label based on an index between 1 and the number of labels available. The effect when the index variable is not in range was undefined from Fortran I through the Fortran 66 standard. Fortran 77 defined an out of range index to continue on to the following statement. The computed GOTO is on the obsolescence list, though as of Fortran 2008 still hasn't been removed. As indicated, it can be replaced by a SELECT CASE construct. But a SELECT CASE with a large number of GOTO statement has to be uglier and less readable than a computed GOTO statement. -- glen