J3/13-245 To: J3 From: Malcolm Cohen Subject: Interp F03/0064 Date: 2013 February 13 ---------------------------------------------------------------------- NUMBER: F03/0064 TITLE: Recursive declaration of procedure interfaces KEYWORDS: procedure, interface DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: Q1. Consider the following program: PROGRAM foo PROCEDURE(sub) :: p INTERFACE SUBROUTINE sub(p2) IMPORT p PROCEDURE(p) :: p2 END SUBROUTINE END INTERFACE END PROGRAM C1216 appears to prohibit the case of an interface name in a procedure declaration statement being the name of something declared in a later procedure declaration statement. But it does not appear to prohibit the case of an interface name being the name of something declared in a later interface body. In the above program, the characteristics of p rely on the characteristics of sub. The characteristics of sub, in turn, rely on the characteristics of p. Is this program standard-conforming? Q2. Consider the module MODULE m1 CONTAINS SUBROUTINE s(p) PROCEDURE(s) :: p END SUBROUTINE END MODULE Constraint C1216 does not apply here since "s" is not declared by a procedure declaration statement; unlike Q1, it is also not declared by an interface body. However, the characteristics of S have not been determined before the procedure declaration statement has been processed, and that cannot be processed until we know what the interface of S is. Is this program unit standard-conforming? Q3. Consider the module MODULE m2 CONTAINS SUBROUTINE s1(a) PROCEDURE(s2) :: a END SUBROUTINE SUBROUTINE s2(b) PROCEDURE(s1) :: b END SUBROUTINE END MODULE The interface of A depends on the interface of S2, which depends on the characteristics of B, which depends on the characteristics of S1, which depends on the characteristics of A; a circular dependency. Is this program unit standard-conforming? Q4. Consider MODULE m3 PROCEDURE(s),POINTER :: sptr CONTAINS SUBROUTINE s(p) PROCEDURE(sptr) :: p END SUBROUTINE END MODULE In the normal course of events there is no problem declaring a procedure pointer to have the interface of a module procedure that is defined later, and this is desirable, but in this case there seems to be a circular dependency between the characteristics of sptr, s, and p. Is this program unit standard-conforming? ANSWER: None of the examples are standard-conforming, as the standard does not establish an interpretation for them. An edit is provided to clarify this. EDIT to 10-007r1: [288:3] 12.4.3.6p2, append new sentence "The interface specified by shall not depend on any characteristic of a procedure identified by a in the of the same procedure declaration statement." SUBMITTED BY: Rob James HISTORY: 05-179 m172 F03/0064 submitted 05-226 m173 Passed by J3 meeting 06-133 m175 Failed J3 letter ballot #12 09-149 m187 Passed by J3 meeting 09-187r2 m188 Failed J3 letter ballot #18 09-155 13-nnn m200 Revised ----------------------------------------------------------------------