(j3.2006) (SC22WG5.4809) Preliminary result of interps ballot 4
Van Snyder
Van.Snyder
Mon Oct 1 18:02:02 EDT 2012
While reading ballot comments on F08/0054, and reviewing the relevant
text in 12.4.2.2, I became convinced that the present wording is not
sufficiently precise. I agree with Malcolm that an interp isn't the
correct vehicle to correct it. I also understand Bob's point concerning
the distinction between the procedure and its identifier(s) having
explicit interface.
Consider
module M
external :: X
end module M
program P
use M, only: XX => X
interface
subroutine X ( A )
real, optional :: A
end subroutine X
end interface
1 call XX
2 call X ( 1.0 )
end program P
The identifiers XX and X identify the same procedure.
Statement 1 is surely intended to be prohibited, because the external
subprogram X, identified by XX in this scope, has an optional argument.
Since the procedure identified by XX does have an explicit interface,
named X, within P, one might argue that this allows statement 1. This
is clearly nonsense because XX isn't "the procedure" within P. "The
procedure" is the entity defined by a subprogram (or by means other than
Fortran). Nonetheless, the sloppy wording of 12.4.2.2 appears to allow
statement 1.
We need to be careful to draw the distinction between the procedure
having explicit interface within a scoping unit, and the identifier used
to reference it, having explicit interface.
One might argue that, within P,
type :: T
contains
procedure XX
end type T
and
interface G
procedure XX
end interface
are allowed, since XX identifies X, and X has explicit interface within
P. Clearly, we did not intend this. So maybe C465 and C1207 need
attention as well. Something like
C1207 (R1206) A <procedure-name> shall have explicit interface and shall
not identify an intrinsic procedure.
I think the only way that a procedure can have several specific
identifiers within a scoping unit is by way of renaming during USE.
Bob also mentioned the distinction between generic and specific
procedure identifiers. A reference using a generic identifier for a
procedure can only appear where it is invoked -- not as an actual
argument, or a <proc-pointer-target>, or a <proc-interface>, or a
<procedure-name> in a <type-bound-proc-decl>. It is always resolved to
a specific procedure, whose identifier at the point of invocation
necessarily has explicit interface (even if it's private).
There might be problems in this area. For example, C1227 says "A
<procedure-name> [in a <procedure-designator>] shall be the name of a
procedure or procedure pointer. I can't find where we get around to
saying that a <generic-name> is the name of a procedure. Indeed,
12.4.3.2 never gets around to saying what an interface block does.
12.4.3.4.1 says that a generic name refers to all of the procedure names
in the interface block. This perhaps ought to be in 12.4.3.2. It also
appears to prohibit using generic names as procedure designators, since
C1227 says "a procedure." Maybe R1221 needs "<<or>> <generic-name>".
Maybe also "<<or>> <data-ref> % <generic-spec>", although 1.3.13 says a
binding name (not <binding-name>) can refer to a generic type-bound
procedure.
More information about the J3
mailing list