(j3.2006) NAME= for internal procs
Van Snyder
van.snyder
Wed Jan 10 15:28:19 EST 2007
Not to pick at old scabs, but... we had a discussion some time ago
concerning multiple interface bodies for a single C procedure (or even a
C-interoperable Fortran procedure referenced as though it were a C
procedure).
Assume the procedure is not a dummy procedure and the interface body
isn't abstract, i.e., it really is external.
There were two camps:
Camp 1: The interface body declares an external procedure and therefore
an external procedure name. Therefore, in an entire program, one can
only have one interface body with a particular binding label, even if if
the several you might wish to have would all have the same Fortran name.
Camp 2: Since the interface body is for a C procedure, the Fortran
processor shouldn't be creating external labels from its Fortran
identifier; these just confuse the linker. Thus, a program can have as
many interface bodies with a particular binding label, even if they have
different Fortran names. The external thing-o that the processor
generates when the procedure is referenced ought always to be the
binding label, never the Fortran name; otherwise the linker will be
confused.
"A procedure shall not have more than one explicit specific interface in
a given scoping unit" at [07-007:302:17-18] could be construed to
require the Camp 1 interpretation, at least within a scoping unit.
OTOH, one could argue that different interface bodies declare different
procedures that happen to be defined by the same stuff in the companion
processor (might or might not be a subprogram, depending upon whether
the companion processor is Fortran), or that we actually mean a
procedure *name* shall not have more than one explicit specific
interface in a giving scoping unit.
I lean toward the Camp 2 interpretation. Consider
module A
interface; subroutine DoIt ( ... )
...
end subroutine DoIt; end interface
end module A;
module B
interface; subroutine DoIt ( ... )
...
end subroutine DoIt; end interface
end module B;
program P
use A, only: MyWay => DoIt
use B, only: TheOnlyWay => DoIt
...
if ( x < 0 ) then
call MyWay ( ... )
else
call TheOnlyWay ( ... )
end if
end program P
I suspect we intended that this program conforms, but [07-007:302:17-18]
appears to say otherwise: DoIt has two explicit specific interfaces in
P. This would be equally true if DoIt were defined by a module
procedure in a third module. 11.2.2 "The USE statement and use
association" explicitly says that "an accessible entity in the
referenced module has one or more local identifiers." It doesn't say
that a <rename> phrase on a USE statement creates a new entity.
Do we need a note, or normative text, or maybe even an interp to make
clear which camp the standard is in?
--
Van Snyder | What fraction of Americans believe
Van.Snyder at jpl.nasa.gov | Wrestling is real and NASA is fake?
Any alleged opinions are my own and have not been approved or
disapproved by JPL, CalTech, NASA, the President, or anybody else.
More information about the J3
mailing list