(j3.2006) should it make a difference if the interface is explicit or implicit?

Robert Corbett Robert.Corbett at Sun.COM
Mon May 25 01:40:48 EDT 2009


Bill Long wrote:

Thank you for your response.

> If the dummy argument has an implicit interface, then the corresponding 
> actual may have an implicit interface (essential for legacy codes) or an 
> explicit interface.  A programmer should be allowed to specify an 
> explicit interface  (which could be useful for reasons unrelated to the 
> call in question) for the actual argument  procedure and still be able 
> to pass that procedure to legacy library codes that have dummies with 
> implicit interfaces.  You don't want to break existing, conforming code 
> because you added an explicit interface. 

I agree with both the semantics you stated and your rationale.

> If the dummy argument has an explicit interface, then the corresponding 
> actual needs to have an interface for which a specified set of 
> characteristics match.   That's because the  uses of the  dummy can 
> assume these characteristics are valid for the actual.  However, I don't 
> see where the standard actually requires that the interface in the 
> caller for the actual argument has to be explicit (unless it's required 
> for other reasons, such as having optional arguments).

I was mistaken.  I read the part of Section 12.4.1.3 that states

     If the interface of the dummy argument is explicit, the
     characteristics listed in 12.2 shall be the same for the
     associated actual argument and the corresponding dummy
     argument, except ...

and the part of Section 12.2.1.2 that states

     The characteristics of a dummy procedure are the explicitness
     of its interface (12.3.1), ...

put the two together and drew an incorrect conclusion.  I had missed
that explicitness of the interface of the dummy procedure is not a
characteristic of the dummy procedure, but is a characteristic of the
procedure of which the dummy procedure is a dummy argument.

> The required 
> characteristics can match without spelling them out in an explicit 
> interface.   Having the explicit interface in the caller does not do the 
> called procedure any good - it goes by the interface specified for the 
> corresponding dummy. Unless the compiler does global interface checking, 
> there is no cross-checking benefit to the user.    So I don't see any 
> motivation to require an explicit interface for the actual just because 
> the dummy has one. It is just required that the programmer meet the 
> requirements of matching characteristics.

I thought the requirement might be linked to the description of a
possible implementation of procedures in Section C.9.5 of the
Fortran 2003 standard (page 481, lines 20 - 25).  Under that scheme, the
explicitness of the interfaces might determine how the subprogram is
invoked.  I see that that text has been dropped from the Fortran 2008
draft.

Bob Corbett


More information about the J3 mailing list