Re: Array Constructors




<cjk32@xxxxxxxxx> wrote in message
news:1172660739.879054.15000@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello,

Can anyone confirm that when a variable is used in an implied do loop
in an array constructor, is its value always restored afterwards.

Please note that the do variable of an implied-do in a DATA statement or an
array constructor has a scope that is just the implied-do. It is different
from any other entity with the same name (i.e., you have two variables
called i in your snippet, so to think about 'restoring' is not correct).
(See also MR&C, Section 5.15.)

Regards,

Mike Metcalf


.



Relevant Pages

  • Re: Scope of implied-do index
    ... in a DATA statement or an array constructor has the scope of the implied-DO list. ... It is a scalar variable that has the type and type parameters that it would have if it were the name of a variable in the scoping unit that includes the DATA statement or array constructor, and this type shall be integer type." ... Aside from the fact that they're not included in the above quote, consider section 14.7.5, which includes "Beginning of execution of the action specified by an implied-DO list in an input/output statement causes the ... section 9.4.2 requires that the variable for an i/o implied-do be a scalar variable; this restriction is not there for array-constructor or data implied-do loops. ...
    (comp.lang.fortran)
  • Re: Scope of implied-do index
    ... of an implied-do is limited to the implied-do. ... array constructor has a scope of its data-implied-do. ... ....then y again gets its type from implicit typing, and ends up as a real. ... this last 'program' should cause a compiler to barf. ...
    (comp.lang.fortran)
  • Re: Array Constructors
    ... in an array constructor, is its value always restored afterwards. ... array constructor has a scope that is just the implied-do. ... That was my initial thought, but IVF complaining if *a* variable, i, ...
    (comp.lang.fortran)
  • Re: Scope of implied-do index
    ... of an implied-do is limited to the implied-do. ... "The name of a variable that appears as the DO variable of an implied-DO in a DATA statement or an array constructor has the scope of the implied-DO list. ... section 9.4.2 requires that the variable for an i/o implied-do be a scalar variable; this restriction is not there for array-constructor or data implied-do loops. ... The text for input/output implied-do loops is similar, but includes the additional requirement that the variables in nested input/output implied-do loops shall not be associated -- which distinction makes sense with the fact that their scope is beyond that of the implied-do loop; the association would be irrelevant if they're not really the same variable as the one in the outer context. ...
    (comp.lang.fortran)