Re: NAG, Sun, Compaq possible f95 bug

From: Richard Maine (nospam_at_see.signature)
Date: 02/03/04


Date: Tue, 03 Feb 2004 08:13:19 -0800

glen herrmannsfeldt <gah@ugcs.caltech.edu> writes:

> Also, the range of a DO loop does not include the DO statement
> itself. Would the scope include the DO?

Range of a DO loop and scope are different (as you allude).
The variable of an "ordinary" DO loop has scope of the
scoping unit that the DO appears in; this is considerably more
than the range of that DO loop. That point is important, as
the variable gets its initial value from statements that are
nefore the DO loop; they are outside of the range of the DO
loop, but in the scope of th evariable.

The scope of an ac-implied-do variable is the ac-implied-do, which
syntactically, includes the whole thing, including the limit
expressions. That's why the limit expressions can't use the
"i" from outside the ac-implied-do; that one isn't in scope.

P.S. People presumably understand, but when I earlier said that
CVF was right, that wasn't mean to say that Lahey was nonconforming
in this regard. The code in question was nonconforming (but doesn't
violate a numbered syntax rule or constraint or any of the other
things requiring diagnosis), and thus the compiler is allowed to
do anything with it. CVF was correct in diagnosing the error,
but Lahey cannot strictly said to be incorrect in giving it some
extended interpretation (I'd say Lahey's behavior was undesirable,
but does not constitute a nonconformance of the compiler.)

-- 
Richard Maine                       |  Good judgment comes from experience;
email: my first.last at org.domain  |  experience comes from bad judgment.
org: nasa, domain: gov              |        -- Mark Twain


Relevant Pages

  • Re: compiler problem
    ... >i is out of scope after the end of the first for loop. ... > code so that it was standard compliant. ... Visual C++ Compiler Team ...
    (microsoft.public.dotnet.languages.vc)
  • Re: About String
    ... My idea is that every statement list is a scope. ... You declare something inside a loop body, ... The same sense as declare blocks. ... SCOPE [DECLS] STATEMENTS END-SCOPE ...
    (comp.lang.ada)
  • Re: Which scope for variables being used in a loop?
    ... can't be GC'd until the scope they are declared in exist. ... inside of the loop. ... overlay local allocations in another loop. ... declaration itself, such that the pointer-value of the variable is ...
    (comp.lang.java.programmer)
  • Re: VS.NET scope of variable declared in for statement
    ... placeholder for a user type in the discussion, and the for loop is just a ... placeholder for a more involved loop using that object. ... >> will be wrong on compilers that scope the variable outside the block. ... >> If you assume scope is outside, a compiler that scopes it inside will ...
    (microsoft.public.vc.language)
  • Re: Scope Best Practice
    ... creating a new object versus the cost of maintaining it in memory?" ... the object is ready for GC once the loop is complete ( ... even if it remains in scope because it is not being referenced anywhere ...
    (microsoft.public.dotnet.languages.csharp)