To: J3 J3/24-166r1 From: generics Subject: Miscellaneous edits to incorporate templates Date: 2024-October-22 References: 24-161, 24-162, 24-163, 24-164, 24-165, 24-125r5, 24-126r4, 24-127r4, 24-007 UTI: Section 4 does not seem to state where it goes in the standard 1. Introduction =============== This paper describes various edits to the standard that are necessary to incorporate the syntax and semantics for templates. The contents of this paper are: Section 2: Edits required for deferred arguments Section 3: Edits required for templates and instantiation Section 4: Edits to TKR compatibility Section 5: Edits for processor dependencies 2. Edits required for deferred arguments ======================================== * Insert new glossary term in 3.7 [deferred argument association] association between an instantiation argument and a deferred argument (Sec. ?) * Insert new glossary term [deferred argument] named entity that appears in a (Sec. ?) * Insert new glossary term 3.34.x [deferred constant] a deferred argument with the PARAMETER attribute [instantiation argument] argument to an INSTANTIATE statement or inline instantiation * 7.3.2.1 Type specifier syntax Extend R702 : <> Extend C703 from: (R702) The shall not specify an abstract type (7.5.7) To: (R702) The or shall not specify an abstract type (7.5.7) except when used as an . Extend R703 to include: <> TYPE() <> CLASS() Change C706 from: (R703) TYPE() shall not specify an abstract type (7.5.7). To: (R703) In a that uses the TYPE keyword, or shall not specify an abstract type (7.5.7). Extend C705 from: (R703) In a that uses the CLASS keyword, shall specify an extensible type (7.5.7). To: (R703) In a that uses the CLASS keyword, or shall specify an extensible type (7.5.7). * 7.5.2.1 Syntax of a derived-type definition Insert new constraint on R728: C737b (R728) shall not be a . * 8.5.2 Accessibility attribute [106:6] In C817, insert "or template" after "module", so that it now reads: C817 An access-spec shall appear only in the specification-part of a module or template construct. * 8.6.1 Accessibility Statement [120:28] Change C873 to read: C873 (R831) An shall appear only in the of a module or template. Only one accessibility statement with an omitted is permitted in the of a module or template. [120:30] Change C874 to read: C874 (R831) Each shall be the name of a module, variable, procedure, nonintrinsic type, named constant other than a deferred constant, namelist group, requirement, or template. [120:37+] In 2nd sentence of paragraph 1, insert "or template" after "in the module" in both locations such that the sentence now reads: An access-stmt without an access-id list specifies the default accessibility of the identifiers of entities declared in the module or template, and of entities accessed from a module whose name does not appear in any access-stmt in the module or template. [120:43] In last sentence of paragraph 1, insert "or template" after "in a module" such that the sentence now reads: If no such statement appears in a module or template, the default is public accessibility. [121:1] In 1st sentence of paragraph 2, insert "or template" after "in the module" such that the sentence now reads: If an identifier is accessed by use association and not declared in the module or template, and the name of every module from which it is accessed appears in an access-stmt in the scoping unit, its default accessibility is PRIVATE if the access-spec in every such access-stmt is PRIVATE, or PUBLIC if the access-spec in any such access-stmt is PUBLIC. * 8.5.8.1 General Change last entry for from: <> To: <> * 8.5.8.2 Explicit-shape array Note: It may be better to modify to disambiguate for lower and upper bounds. This would make constraint for deferred constants clearer. * 8.5.8.6 Implied-shape array Modify the first sentence from: An implied-shape array is a named constant that takes its shape from the constant-expr in its declaration. To: An implied-shape array is a named constant that takes its shape from a constant expression. If it is a deferred constant, it takes its shape from the associated instantiation argument, otherwise it takes its shape from the constant expression in its declaration. Delete the first sentence in the last paragraph which reads: The extent of each dimension of an implied-shape array is the same as the extent of the corresponding dimension of the constant-expr. Insert new section after 8.5.8.7 8.5.8.7b Implied-rank entity An implied-rank entity is an entity whose rank becomes defined only when the template in which it appears is instantiated. Note: Also make sure it works with SELECT GENERIC RANK and spell out what can be done with implied-rank entities. R287b <> .. C841b (R287b). An implied-rank entity shall be a . Note: Examples of implied-rank entities TEMPLATE EXAMPLE(C, S, N) INTEGER, DEFERRED, PARAMETER :: C(..) ! implied-shape & implied-rank INTEGER, DEFERRED, PARAMETER :: S(*), N INTEGER, PARAMETER :: B(S) = 1 ! explicit-shape & implied-rank END TEMPLATE * 8.5.17 RANK clause Replace constraint C864 which states: C864 An entity declared with a rank-clause shall be a dummy data object or have the ALLOCATABLE or POINTER attribute. With: C864 An entity declared with a rank-clause shall be a named constant, dummy data object or have the ALLOCATABLE or POINTER attribute. Replace the last paragraph: If the rank is zero the entity is scalar; otherwise, if it has the ALLOCATABLE or POINTER attribute, it specifies that it is a deferred-shape array; otherwise, it specifies that it is an assumed-shape array with all the lower bounds equal to one. With: If the rank is zero the entity is scalar; otherwise, if it has the ALLOCATABLE or POINTER attribute, it specifies that it is a deferred-shape array; otherwise, if it is a named constant, it specifies that it is an implied-shape array with all lower bounds equal to one; otherwise, it specifies that it is an assumed-shape array with all the lower bounds equal to one. * 8.6.1 Accessibility statement Modify C873 to read as C873 An shall appear only in the of a module or template construct. Only one accessibility statement with an omitted is permitted in the of a module or template construct. * 10.1.12 Constant expression Extend list in normative text for "constant expression": "deferred constant" * 10.1 Expressions and Assignment New section 10.1.13 Deferred constant expressions <> An expression is a if one or more of its primaries is a deferred constant. A is not equal to any other unless is syntactically equivalent. * 11.1.11.1 Purpose and form of the SELECT TYPE construct Extend R1156 to R1156 <> TYPE IS ( ) [ ] <> CLASS IS ( ) [ ] <> CLASS IS ( ) [ ] <> CLASS DEFAULT [ ] Add constraint: C116b (R1156). shall specify an extensible type. * 15.5.1 Syntax of a procedure reference UTI: spelling of vs Extend R1522 with: <> <> Extend R1524 with: <> <> 3. Edits required for templates and instantiation ================================================= * 5.1 High level syntax Extend R508 to include: <>