(j3.2006) scope of implicitly declared entities in BLOCK constructs
Bill Long
longb at cray.com
Fri Mar 6 11:28:31 EST 2009
Robert Corbett wrote:
> As the draft Fortran 2008 standard is currently written,
> a data entity that is implicity declared in a BLOCK
> construct has the scope of the outermost scoping unit
> that contains it. Thus,
>
> PROGRAM MAIN
> BLOCK
> I = 10
> END BLOCK
> PRINT *, I
> END
>
> conforms to the draft standard, but
>
> PROGRAM MAIN
> BLOCK
> INTEGER I
> I = 10
> END BLOCK
> PRINT *, I
> END
>
> does not. Is that the intent of the committee?
>
>
I hope so. One obvious use of a block construct is to put BLOCK and END
BLOCK around an existing section of code for the purpose of adding a
new, local declaration and some additional statements using the new
variables. You don't want previously present variables in the section
of code to suddenly have their scoping change. If that were to happen,
you would end up with unexpected, and hard to track-down bugs.
Cheers,
Bill
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120
More information about the J3
mailing list