(j3.2006) question about multiple duplicate local identifiers in Fortran 2003
Wed Apr 23 14:47:50 EDT 2008
Michael Ingrassia wrote:
> The program
> INTERFACE T
> FUNCTION F(J)
> END FUNCTION
> END INTERFACE
> TYPE T
> INTEGER :: I
> END TYPE T
> EXTERNAL F
> PRINT *, F(T(17))
Two errors will might prevent this from compiling independent of the
question below. The EXTERNAL F should not be there since F is already
defined in an explicit interface above. Also, the reference F(T(17))
has the wrong type argument, independent of which interpretation of
T(17) you prefer (either type REAL in the function case, or TYPE(T) in
the constructor case - neither is integer which is the argument type for F).
> uses the name T as both a generic name and as the name of a derived type.
> Constraint C489 [04-007:63:39] rules out the syntax T(17) as a valid
> structure constructor.
One could argue that T(17) directly violates C489. However, if that's
the case, then what is the point of Note 4.56 which says, basically,
that if the reference appears to be ambiguous, then the function
reference wins. Based on user feedback on OOPS stuff, users really want
the capability to "override" a structure constructor with their own
function, and hence want the capability implied by the Note.
So, to be specific, (after fixing the interface), if this definition of
F is added:
integer function f(k)
f = k*2
then would the program print out 68? I think that's what the users want.
> But I don't see a prohibition against the syntax
> T(17) as a generic function reference, in which case the PRINT statement has an
> unambiguous interpretation. Was it intended that the program be
> --Michael I.
> J3 mailing list
> J3 at j3-fortran.org
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