Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #1346

Re: How to type braces for computed gotos

From glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups comp.compilers
Subject Re: How to type braces for computed gotos
Date 2014-07-23 00:35 +0000
Organization Aioe.org NNTP Server
Message-ID <14-07-056@comp.compilers> (permalink)
References <14-05-013@comp.compilers> <14-07-033@comp.compilers> <14-07-048@comp.compilers> <14-07-054@comp.compilers>

Show all headers | View raw


William Clodius <wclodius@earthlink.net> wrote:

(snip on labeled variable GOTO, Fortran ASSIGNed GOTO, and such)

> Not quite the rough equivalent of a C switch statement is the Fortran 90
> SELECT CASE. A Fortran computed GO TO, as with an assigned GO TO, does
> not have a syntactic block associated with it, and can be set up to go
> to any label within the current program or sub-program.

Well, there is no rule that you have to write ugly code in Fortran.
You can indent and comment, and otherwise arrange things in a more
orderly way.

In the case of computed GOTO, you could arrange the code for each
choice one after another, in the same order as the labels, and with
comments indicating which choice went to each one.

If you consider something like Duff's device, then it isn't so obvious
that computed GOTO is so different from C's switch/case.  (Well, when
the labels are sequential starting at one.)

As I noted previously, the Fortran standard now considers SELECT CASE
as a replacement for computed GOTO, though the latter hasn't yet been
removed from the standard.

-- glen

Back to comp.compilers | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Best "simple" C Compiler I've ever seen andrewchamberss@gmail.com - 2014-05-04 18:23 -0700
  Re: Best "simple" C Compiler I've ever seen federation2005@netzero.com - 2014-06-30 12:42 -0700
  How to type braces for computed gotos (was: Best "simple" C Compiler I've ever seen) federation2005@netzero.com - 2014-07-18 14:44 -0700
    Re: How to type braces for computed gotos glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-07-19 02:21 +0000
      Re: How to type braces for computed gotos Ivan Godard <ivan@ootbcomp.com> - 2014-07-18 21:59 -0700
      Re: How to type braces for computed gotos federation2005@netzero.com - 2014-07-21 10:32 -0700
    Re: How to type braces for computed gotos (was: Best "simple" C Compiler I've ever seen) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-07-21 11:45 +0000
      Re: How to type braces for computed gotos glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-07-21 16:19 +0000
      Re: How to type braces for computed gotos wclodius@earthlink.net (William Clodius) - 2014-07-21 21:44 -0600
        Re: How to type braces for computed gotos glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-07-23 00:35 +0000
          Re: How to type braces for computed gotos wclodius@earthlink.net (William Clodius) - 2014-07-22 22:36 -0600
            Re: How to type braces for computed gotos anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2014-07-25 22:38 -0400

csiph-web