Clicky

Fortran Wiki
Uniform syntax for block constructs

Proposal: all block constructs should share a common syntax as much as possible. Fortran 2008 incorporates EXIT into non-DO constructs, which is a step in the direction of uniformity.

1) Label-DO should be deprecated. DO is the only block construct that supports a line-label end marker, making it an obvious outlier. Presumably, label-do is supported mainly for legacy reasons. (Alternatively, all constructs should have a label form, if there is resistance to deprecating label-do. However, newer Fortran standards clearly disfavor the use of labels.)

2) DO syntax should have the loop-control in parenthesis. For example:

  DO (I=1,100)
    X(I)=X(I)**2
  END DO

3) Where relevant, constructs should have a single-line form, similar to IF statements. Item #2 is helpful here. For example:

  DO (I=1,100) X(I)=X(I)**2
  ASSOCIATE(i => my%data%array(index_of('hello'))) i=i+1

4) Support CYCLE where possible. In a set of IF-THEN-ELSEIF blocks, CYCLE could exit the current THEN block, and go to the next ELSEIF block. Applying the same logic to SELECT-CASE, CYCLE would jump the the CASE DEFAULT, because cases are always non-overlapping. (Note: this would fit better if Fortran used the keyword NEXT, which is Perl’s equivalent of CYCLE)