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

Van Snyder van.snyder at jpl.nasa.gov
Sun May 24 15:10:18 EDT 2009


It is irrelevant whether an actual procedure argument has an explicit 
interface unless it's also invoked in the calling scoping unit.

What counts is the relationship between the procedure that ultimately 
gets invoked and the intereface it has in the scoping unit where it's 
invoked.

It is possible, for example, to write an external procedure that has, 
say, an optional argument, mention it only in an EXTERNAL statement, 
pass it as an actual argument, perhaps through a chain of procedure 
references where it's again only mentioned in EXTERNAL statements, and 
ultimately invoke it by way of a dummy argument.  Only where it is 
invoked does the interface need to be explicit.

Bill Long wrote:
> 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. 
>
> 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).  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.
>
> Cheers,
> Bill
>
>
>
> Robert Corbett wrote:
>   
>> Suppose a routine that can have implicit interface is passed as an
>> actual argument that becomes associated with a dummy procedure.  If
>> the dummy procedure has explicit interface, is the actual argument
>> required to have explicit interface?  If the dummy procedure has
>> implicit interface, is the actual argument required to have implicit
>> interface?
>>
>> My reading of Section 12.4.1.3 of the Fortran 2003 standard is that
>> if the dummy procedure has explicit interface, then the actual
>> argument must have explicit interface, but if the dummy procedure
>> has implicit interface, the actual argument can have either implicit
>> or explicit interface.  Is that the intended semantics?
>>
>> Bob Corbett
>> _______________________________________________
>> J3 mailing list
>> J3 at j3-fortran.org
>> http://j3-fortran.org/mailman/listinfo/j3
>>   
>>     
>
>   




More information about the J3 mailing list