J3/13-304r1 To: J3 From: Van Snyder & Malcolm Cohen Subject: Edits for US-04 Control host association Date: 2013 October 13 1. Introduction --------------- This paper contains specifications, syntax, and edits, for requirement US-04 that has been approved as a 2015 feature. 2. Specifications ----------------- (a) To be able to specify that an entity is host-associated. (b) To be able to limit host association to a specific list of names; this shall include the empty set. (c) To be able to prevent inadvertent "shadowing" of host names. (d) No renaming. 3. Syntax --------- (a) Allow IMPORT to be used in a hosted subprogram or BLOCK construct, not just in interface bodies. But not in derived types or in any other construct. (b) Add an "ONLY" clause to IMPORT. To avoid confusion, if any IMPORT statement in a scoping unit has an "ONLY" clause, all the IMPORT statements in that scoping unit shall have ONLY clauses. Although "IMPORT,ONLY:" specifying no entities would appear to satisfy the requirement for preventing import, it does not do so clearly as a subsequent "IMPORT,ONLY: ..." might extend that empty set. Therefore a specific "IMPORT,NONE" statement should be added; if an IMPORT,NONE statement appears in a scoping unit, no other IMPORT statement shall appear in that scoping unit. (c) Add an "IMPORT,ALL", which explicitly imports every host entity; it differs from a blank "IMPORT" (or the default host association) which only imports entities that are not locally declared. An entity imported with IMPORT,ALL shall not be declared locally except to have the ASYNCHRONOUS or VOLATILE attribute. ::= IMPORT [[ :: ] ] | IMPORT, ONLY : | IMPORT, NONE | IMPORT, ALL The prohibitions listed in (a)-(c) shall be constraints. Additional requirements beyond those specified in 13-238r1: (d) IMPORT, NONE shall be constrained not to appear in a submodule. (e) The existing requirements in 12.4.3.3p1 and p2 shall be made into constraints. 4. Notes re 13-304 ------------------ The proposed constraint C1211c was already completely covered by existing constraint C1208. 5. Edits to 10-007r1 -------------------- [Introduction p2+] In the new list of new features, add o Scoping units: The IMPORT statement can appear in contained subprograms and BLOCK constructs, and can restrict access via host association. Diagnosis of violation of the IMPORT restrictions is required. [12.4.3.3 282:2] Replace R1209: R1209 <> IMPORT [[ :: ] ] <> IMPORT, ONLY : <> IMPORT, NONE <> IMPORT, ALL [12.4.3.3 282:3-4] Replace C1210: C1210 (R1209) An IMPORT statement shall not appear in the of a , , , or . [12.4.3.3 282:5+] Add constraints: C1211a If any IMPORT statement in a scoping unit has an ONLY specifier, all IMPORT statements in that scoping unit shall have an ONLY specifier. C1211b IMPORT, NONE shall not appear in a submodule. C1211d If an IMPORT, NONE or IMPORT, ALL statement appears in a scoping unit, no other IMPORT statement shall appear in that scoping unit. C1211e 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. C1211f An entity whose name appears as an or which is made accessible by IMPORT ALL shall not appear in any context described in 16.5.1.4 that would cause the host entity of that name to be inaccessible. [12.4.3.3p1-2 282:6-15] Replace paragraphs 1-2: "If the ONLY specifier appears on an IMPORT statement in a scoping unit, an entity is only accessible by host association if its name appears as an in that scoping unit. An IMPORT, NONE statement in a scoping unit specifies that no entities in the host scoping unit are accessible by host association in that scoping unit. This is the default for an interface body for an external or dummy procedure. An IMPORT, ALL statement in a scoping unit specifies that all entities from the host scoping unit are accessible by host association in that scoping unit. If an IMPORT statement with no appears in a scoping unit, every entity in the host scoping unit is accessible unless its name appears in a context described in 16.5.1.4 that causes it to be inaccessible. This is the default for a nested scoping unit other than an interface body for an external or dummy procedure. If an IMPORT statement with an appears in a scoping unit, each named entity from the host scoping unit is accessible by host association." [282:15+] Add notes with examples "NOTE 12.4a IMPORT NONE can be used to prevent accidental host association: SUBROUTINE s(x,n) IMPLICIT NONE IMPORT NONE ... DO i=1,n ! Forces I to be locally declared. NOTE 12.4b IMPORT ALL can be used to confirm the default rules and prevent accidental "shadowing" of host entities: SUBROUTINE outer REAL x ... CONTAINS SUBROUTINE inner IMPORT ALL ... x = x + 1 ! X was prevented from being locally declared... ! so must be the host X. NOTE 12.4c IMPORT ONLY can be used to document deliberate access via host association whilst blocking accidental access: SUBROUTINE sub IMPORT,ONLY :: x, y ... x = y + z ! X and Y imported, Z must be local." [16.5.1.4p1 443:27-31] Replace the first 3 sentences "An ... body." with "A nested scoping unit has access to named entities from its host as specified in \ref{D12: IMPORT statement}." ===END===