(j3.2006) badly worded semantics for the IMPORT statement
Tue Dec 4 14:40:09 EST 2007
Robert Corbett wrote:
>> I'd note that essentially the same statement appears twice, at [260:4-5]
>> and [260:11-12], but with different sentence structure. My wording
>> above follows more closely the second sentence in the standard. Maybe
>> it would be clearer, and more consistent, to use the same sentence form
>> in both places.
>> Robert Corbett wrote:
>>> Someone here at Sun recently asked why it made a difference whether
>>> a variable named in an IMPORT statement was assigned a value. He
>>> pointed out that Section 126.96.36.199 of the Fortran 2003 standard states
>>> An entity that is imported in this manner and is defined
>>> in the host scoping unit shall be explicitly declared
>>> prior to the interface body.
>>> Perhaps it would be better to say "declared" instead of "defined."
>>> Bob Corbett
> Consider the module
> MODULE MOD
> SUBROUTINE SUBR(A)
> DIMENSION A(N)
> END SUBROUTINE
> END INTERFACE
> INTEGER, PARAMETER :: I = BIT_SIZE(N)
> END MODULE
> Applying the definition of "definition" given in Section 2.5.5
> literally, this module is standard conforming unless the module
> variable N is assigned a value. That is clearly not what was
> intended, but it is what the standard says. I would prefer for
> the standard to say what it means and means what it says.
> Bob Corbett
I assume you think this module should not be standard conforming. I can
agree with that. How about the same module except where the INTEGER
statement is before the INTERFACE block? If the intent of the standard
is to relieve compilers from having to look ahead for declarations or
definitions, then the modified module would seem OK.
If the only issue is look ahead, then it would seem like the sentence
could be reworded something like:
"An entity that is imported in this manner shall be declared or defined
prior to the interface body."
Note that this also drops the "explicitly" to allow for implicit
declaration, as in your module. Is this what you think the standard
means (or should mean)? I agree that the current wording is muddled,
combining "defined" (applies to variables and types) with "declared"
(does not apply to types). However, I think the proposed alternative
above really does say something different. I think an interp would be
required for such a change.
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