To: J3 J3/21-138r1 From: Van Snyder & Malcolm Cohen Subject: Interp F18/nnn Access Internal Procedure in Interface Body Reference: 18-007r1 Date: 2021-June-21 The r0 of this paper asked the question Was it intended that it be impossible to use an internal subprogram to specify the interface of a dummy procedure in an interface body? The constraint in question says: Within an interface body, an entity that is accessed by host association shall be accessible by host or use association within the host scoping unit, or explicitly declared prior to the interface body. Actually, it is not quite impossible to use an internal procedure name in IMPORT, it merely cannot be done before the declaration (definition) of the internal procedure. So, not in the specification part of the containing main program or subprogram, but could be in a later internal procedure. There is no doubt that IMPORT was intended to be capable only of importing things that were previously declared. As evidence, the text in the standard which did not appear accidentally. This text was part of the IMPORT feature from its beginning in Fortran 2003. (One of the authors of the feature confirms that this was intended to avoid errors such as circular definition, and to reduce impact on implementation, i.e. they don't have to have robust dependency detection or be able to sort declarations by dependency. Whether one agrees with the technical reasons or not, there is no doubt as to the intention.) As such, the question is answered directly without need for interpretation, by the existing text in the standard. It has been long-standing policy of /INTERP that if a question can be answered directly by reference to the text of the standard, without need for complicated reasoning or inference, the question is not accepted as a request for interpretation but simply answered. (This helps to reduce our workload, as interp processing requires multiple rounds of discussion and voting even when everyone agrees.) Therefore, /INTERP declines to accept this request. On examination, it seems to be a new feature, which should be considered on its technical merits. Therefore, /INTERP further recommends that this new feature be considered in the Fortran 202y timeframe. Original text of the r0 follows: ---------------------------------------------------------------------- NUMBER: F18/nnn TITLE: Access Internal Procedure in Interface Body DEFECT TYPE: TBD STATUS: TBD EXAMPLE: Consider: program Test_Internal interface subroutine S1 ( S ) import S2 procedure ( S2 ) :: S end subroutine S1 end interface contains subroutine S2 end subroutine S2 end program Test_Internal C897 (R867) Each shall be the name of an entity in the host scoping unit. S2 satisfies this constraint. It is in the host scoping unit. C8101 Within an interface body, an entity that is accessed by host association shall be accessible by host or use association within the host scoping unit, or explicitly declared prior to the interface body. S2 violates this constraint. It is not, and cannot be, declared before the interface block. Some processors accept the program, and others do not. Interestingly, if a procedure declaration (with or without the POINTER attribute) that uses the internal subroutine to specify its interface appears before the interface block, e.g., procedure ( s2 ), pointer :: P the processor that rejects the program then accepts it. This is not a declaration of S2 that precedes the interface block. QUESTION: Unlike Pascal, Fortran does not have a FORWARD declaration. It is therefore impossible to declare an internal subprogram before an interface block in the host scoping unit. Was it intended that it be impossible to use an internal subprogram to specify the interface of a dummy procedure in an interface body? ANSWER 1: This was intended. ANSWER 2: This was an oversight. EDITS 1: No edits are necessary. EDITS 2: Revise constraint C8101 C8101 Within an interface body, an entity that is accessed by host association shall be accessible by host or use association within the host scoping unit, explicitly declared prior to the interface body, or an internal procedure of the host scoping unit. SUBMITTED BY: Van Snyder HISTORY: 21-138 m224 Submitted ----------------------------------------------------------------------