J3/13-312r1 To: J3 From: Van Snyder Subject: Specifications for US-08 -- explicit specification of EXTERNAL Date: 2013 September 27 Reference: 13-244r1 1. Requirements =============== 1.1 From 13-244r1 and N1982: ---------------------------- " Currently, there is no way to require explicit specification of the external attribute. Providing such a means would aid program checking." 1.2 Feature creep from e-mail: ------------------------------ It would also be desirable to require explicit interface. While we're at it, we could provide alternative syntax for IMPLICIT NONE. 2. Specification ================ 2.1 Based on 13-244r1 and N1982 alone ------------------------------------- Provide a new statement or an annotation or variation of an existing statement that requires explicit declaration of the EXTERNAL attribute. If it appears in a scoping unit, it applies in contained scoping units (BLOCK constructs and internal or module procedures). This is independent from requiring explicit interface for external procedures, which is not contemplated by this work item. 2.2 Feature-crept specification ------------------------------- Provide a new statement or an annotation or variation of an existing statement that can require explicit declaration of the EXTERNAL attribute, or explicit interface. If it appears in a scoping unit, it applies in contained scoping units (BLOCK constructs and internal or module procedures). 3. Syntax proposals =================== Two proposals, based on IMPLICIT NONE and a new statement, have gained some traction. 3.1 Based on IMPLICIT NONE statement and 13-244r1 and N1982 alone ----------------------------------------------------------------- Allow an optional ( EXTERNAL ) annotation after IMPLICIT NONE, meaning that no references to implicitly external procedures are allowed. <> IMPLICIT <> IMPLICIT NONE [ ( EXTERNAL ) ] The specification applies in contained scoping units. {Question: Does IMPLICIT NONE in a scoping unit cancel IMPLICIT NONE ( EXTERNAL ) gotten from the host scoping unit?} 3.1 Based on IMPLICIT NONE statement and feature creep ------------------------------------------------------ Allow an optional annotation list after IMPLICIT NONE, in parentheses, that could include one or more of the words EXTERNAL, INTERFACE, or TYPE, meaning, respectively, that no references to implicitly external procedures are allowed, that all procedure references shall refer to procedures with explicit interface, and that all variables, named constants, and functions shall have explicitly-declared type. The latter is equivalent to IMPLICIT NONE with no annotation. <> IMPLICIT <> IMPLICIT NONE [ ( ) ] <> EXTERNAL <> INTERFACE <> TYPE The specifications apply in contained scoping units. {Question: Does IMPLICIT NONE in a scoping unit cancel a specification in the host scoping unit if it appears without one of the words specified in in the host scoping unit?} 3.3 A new REQUIRE statement based on 13-244r1 and N1982 alone ------------------------------------------------------------- The keyword REQUIRE is a placeholder here; EXPLICIT and NO IMPLICIT have also been proposed. Provide a new REQUIRE [:] EXTERNAL statement, meaning that no references to implicitly external procedures are allowed. <> REQUIRE [:] EXTERNAL The specification applies in contained scoping units. {Question: How does one cancel this within a contained scoping unit? Do we need an ALLOW statement?} The syntax [:] EXTERNAL is a placeholder here. ( EXTERNAL ) has also been proposed. 3.3 A new REQUIRE statement with feature creep ---------------------------------------------- The keyword REQUIRE is a placeholder here; EXPLICIT and NO IMPLICIT have also been proposed. Provide a new REQUIRE statement that can have a list of one or more of the words EXTERNAL, INTERFACE, or TYPE, meaning, respectively, that no implicitly external procedures are allowed, that all procedure references shall refer to procedures with explicit interface, and that all variables, named constants, and functions shall have explicitly-declared type. The latter is equivalent to IMPLICIT NONE. <> REQUIRE [:] <> EXTERNAL <> INTERFACE <> TYPE The specifications apply in contained scoping units. {Question: How does one cancel this within a contained scoping unit? Do we need an ALLOW statement?} The syntax [:] is a placeholder here. ( ) has also been proposed. 4. Straw votes on Syntax ======================== 1. Should specifications be limited to the EXTERNAL attribute, as specified in 13-244r1 and N1982? 2. Should the IMPLICIT NONE statement be augmented, or should a new statement be provided? 3. If the outcome of straw vote #2 is "new statement", should the keyword be REQUIRE or EXPLICIT or NO IMPLICIT? 4. If the outcome of straw vote #2 is "new statement", should the requirement appear in a list after an optional colon, or in a list within parentheses? 5. Draft edits to 10-007r1 ========================== 5.1 Variation on IMPLICIT statement, based on 13-244r1 and N1982 alone ---------------------------------------------------------------------- [Introduction p2+] In the new list of new features, insert a list item: " o Programs and procedures: An IMPLICIT NONE statement can require explicit declaration of the EXTERNAL attribute throughout a scoping unit and its contained scoping units. " [109:2] Replace second alternative of " <> IMPLICIT NONE [ ( EXTERNAL ) ]" [109:7+] Insert constraints " C583a (R560) If IMPLICIT NONE ( EXTERNAL ) appears within a scoping unit, a that is a in a or in that scoping unit shall have explicit interface (12.4.2) or be explicitly declared to have the EXTERNAL attribute (5.3.9) by a type declaration statement (5.2.1), EXTERNAL statement (12.4.3.5), or procedure declaration statement (12.4.3.6). R583c (R562a) IMPLICIT NONE ( EXTERNAL ) shall not appear within a BLOCK DATA program unit. " [109:16+] Insert a paragraph {should this be discussed with different wording at [445:1+]?} "If IMPLICIT NONE ( EXTERNAL ) does not appear in a scoping unit, whether an external or dummy procedure can be referenced if the EXTERNAL attribute is not explicitly declared depends upon specification in the host scoping unit." 5.2 Variation on IMPLICIT statement, with feature creep ------------------------------------------------------- [Introduction p2+] In the new list of new features, insert a list item: " o Programs and procedures: An IMPLICIT NONE statement can require explicit declaration of the EXTERNAL attribute throughout a scoping unit and its contained scoping units, or that all procedure references shall be to procedures having explicit interface. " [109:2] Replace second alternative of " <> IMPLICIT NONE [ ( ) ]" [109:4+] Insert definite of "R562a <> EXTERNAL <> INTERFACE <> TYPE " [109:7+] Insert constraints " C583a (R560) If appears within a scoping unit and is EXTERNAL, a that is a in a or in that scoping unit shall have explicit interface (12.4.2) or be explicitly declared to have the EXTERNAL attribute (5.3.9) by a type declaration statement (5.2.1), EXTERNAL statement (12.4.3.5), or procedure declaration statement (12.4.3.6). C583b (R560) If appears within a scoping unit and is INTERFACE, a that is a in a or in that scoping unit shall have explicit interface (12.4.2). R583c (R562a) EXTERNAL and INTERFACE shall not appear within in an IMPLICIT statement in a BLOCK DATA program unit. " [109:14] After "IMPLICIT NONE" insert or "IMPLICIT NONE ( ) in which TYPE appears". [109:16+] Insert a paragraph {should this be discussed with different wording at [445:1+]?} "If IMPLICIT NONE with EXTERNAL appearing in does not appear in a scoping unit, whether an external or dummy procedure can be referenced if the EXTERNAL attribute is not explicitly declared depends upon specification in the host scoping unit. If IMPLICIT NONE with INTERFACE appearing in does not appear in a scoping unit, whether an external or dummy procedure can be referenced if it has implicit interface, depends upon specification in the host scoping unit." 5.3 A new REQUIRE statement, based on 13-244r1 and N1982 alone -------------------------------------------------------------- [Introduction p2+] In the new list of new features, insert a list item: " o Programs and procedures: A REQUIRE statement can require explicit declaration of the EXTERNAL attribute throughout a scoping unit and its contained scoping units. " [111:1-] Insert a subclause (should this be in clause 12?) " 5.5a REQUIRE statement The REQUIRE statement can specify that the EXTERNAL attribute (5.3.9) shall be explicitly declared. R562a <> REQUIRE [:] EXTERNAL C583a (R560) If a REQUIRE statement appears within a scoping unit, a that is a in a or in that scoping unit shall have explicit interface (12.4.2) or be explicitly declared to have the EXTERNAL attribute (5.3.9) by a type declaration statement (5.2.1), EXTERNAL statement (12.4.3.5), or procedure declaration statement (12.4.3.6). R583c (R562a) A REQUIRE statement shall not appear within a block data program unit. If a REQUIRE statement does not appear in a scoping unit, whether an external or dummy procedure can be referenced if the EXTERNAL attribute is not explicitly declared depends upon specification in the host scoping unit." {should this be discussed at [445:1+] with different wording?} " 5.4 A new REQUIRE statement, with feature creep ----------------------------------------------- [Introduction p2+] In the new list of new features, insert a list item: " o Programs and procedures: A REQUIRE statement can require explicit declaration of the EXTERNAL attribute throughout a scoping unit and its contained scoping units, or that all procedure references shall be to procedures having explicit interface. One form of the REQUIRE statement is equivalent to IMPLICIT NONE. " [111:1-] Insert a subclause (should this be in clause 12?) " 5.5a REQUIRE statement The REQUIRE statement can specify that the EXTERNAL attribute (5.3.9) shall be explicitly declared, that all procedure references shall be to procedures that have explicit interface, or that all data object identifiers have explicitly-declared type. If an REQUIRE statement appears in a scoping unit, its effect applies within all contained scoping units. R562a <> REQUIRE [:] R562b <> EXTERNAL <> INTERFACE <> TYPE C583a (R560) If a REQUIRE statement appears within a scoping unit and is EXTERNAL, a that is a in a or in that scoping unit shall have explicit interface (12.4.2) or be explicitly declared to have the EXTERNAL attribute (5.3.9) by a type declaration statement (5.2.1), EXTERNAL statement (12.4.3.5), or procedure declaration statement (12.4.3.6). C583b (R560) If a REQUIRE statement appears within a scoping unit and is INTERFACE, a that is a in a or in that scoping unit shall have explicit interface (12.4.2). R583c (R562a) If a REQUIRE statement appears within a block data program unit, shall not be EXTERNAL or INTERFACE. If is TYPE the effect is the same as an IMPLICIT NONE statement, and this may be confirmed by explicit specification using an IMPLICIT NONE statement. {"shall not" instead of "may"?} "If a REQUIRE statement with EXTERNAL appearing in does not appear in a scoping unit, whether an external or dummy procedure can be referenced if the EXTERNAL attribute is not explicitly declared depends upon specification in the host scoping unit. If a REQUIRE statement with INTERFACE appearing in does not appear in a scoping unit, whether an external or dummy procedure can be referenced if it has implicit interface, depends upon specification in the host scoping unit." {should this be discussed at [445:1+] with different wording?} "