To: J3 J3/25-108 From: generics Subject: Edits for TEMPLATES: Consistency of deferred args Date: 2025-February-03 References: 25-107, 24-125r5, 24-126r4, 24-127r4 Introduction: ============= This is the 2nd of 6 papers that provide edits for the approved syntax for templates. Section 1: ========== * Append the following to the new clause introduced in paper 25-107. tt.2.2 Consistency of deferred argument specifications tt.2.2.1 General Within a construct with deferred arguments, an explicit specification of a deferred argument is provided by - a , - a , - a , or - an in a deferred interface block in the scoping unit where the deferred argument appeared in a . {The final porition of the above paragraph might be redundant with Ctt04, Ctt11, and Ctt15.} A deferred argument shall have one or more ultimate specifications. The ultimate specifications of a deferred argument are: - an explicit specification, if present, and - its ultimate specifications as instantiation arguments in REQUIRE statements in the scoping unit where the deferred argument appeared in a , if any. The ultimate specifications of an instantiation argument in a REQUIRE statement are the ultimate specifications of the corresponding deferred argument in the referenced requirement construct. Ctt02 A deferred argument shall have at most one explicit specification in a given scoping unit. NOTE 1 A deferred argument is always explicitly declared within the template itself or via a referenced requirement. A deferred argument has at least one ultimate specification. tt.2.2.2 Specification of deferred types Ctt17 If any ultimate specification of a deferred argument is a deferred type, then all ultimate specifications of that deferred argument shall be deferred type. If any ultimate specification of a deferred type has the EXTENSIBLE attribute, then the deferred type has the EXTENSIBLE attribute. If all ultimate specifications of a deferred type have the ABSTRACT attribute, or if the deferred type has an explicit specification with the ABSTRACT attribute, then the deferred type has the ABSTRACT attribute. Otherwise the deferred type does not have the ABSTRACT attribute. NOTE 1 A deferred type with the ABSTRACT attribute is considered an abstract derived type, so it can only be an instantiation argument when the corresponding deferred argument has the ABSTRACT attribute. Therefore, if a deferred type has an explicit specification with the ABSTRACT attribute, all of its ultimate specifications need the ABSTRACT attribute too. NOTE 2 Examples that illustrate valid and invalid uses of ABSTRACT and EXTENSIBLE attributes on deferred types are: REQUIREMENT R_REGULAR(U) DEFERRED TYPE :: U END REQUIREMENT REQUIREMENT R_EXTENSIBLE(U) DEFERRED TYPE, EXTENSIBLE :: U END REQUIREMENT REQUIREMENT R_ABSTRACT(U) DEFERRED TYPE, ABSTRACT :: U END REQUIREMENT Note 3 Given the requirements from NOTE 2 and a deferred argument T, the following lines are valid or invalid as marked. REQUIRE R_REGULAR(T) ! valid, non-extensible REQUIRE R_EXTENSIBLE(T) ! valid, extensible REQUIRE R_ABSTRACT(T) ! valid, abstract DEFERRED TYPE :: T REQUIRE R_REGULAR(T) ! valid, non-extensible DEFERRED TYPE :: T REQUIRE R_EXTENSIBLE(T) ! invalid, explicit decl not extensible DEFERRED TYPE :: T REQUIRE R_ABSTRACT(T) ! invalid, explicit decl not extensible DEFERRED TYPE, EXTENSIBLE :: T REQUIRE R_REGULAR(T) ! valid, T is not abstract DEFERRED TYPE, EXTENSIBLE :: T REQUIRE R_EXTENSIBLE(T) ! valid, decls match DEFERRED TYPE, EXTENSIBLE :: T REQUIRE R_ABSTRACT(T) ! valid, T is just extensible DEFERRED TYPE, ABSTRACT :: T REQUIRE R_REGULAR(T) ! invalid, T is abstract DEFERRED TYPE, ABSTRACT :: T REQUIRE R_EXTENSIBLE(T) ! invalid, T is abstract DEFERRED TYPE, ABSTRACT :: T REQUIRE R_ABSTRACT(T) ! valid, decls match REQUIRE R_REGULAR(T) REQUIRE R_EXTENSIBLE(T) ! valid, T is extensible REQUIRE R_REGULAR(T) REQUIRE R_ABSTRACT(T) ! valid, T is just extensible REQUIRE R_EXTENSIBLE(T) REQUIRE R_ABSTRACT(T) ! valid, T is just extensible tt.2.2.3 Specification of deferred constants Ctt18 If any ultimate specification of a deferred argument is a deferred constant, then all ultimate specifications of that deferred argument shall be deferred constant. Ctt19 All ultimate specifications of a deferred constant shall specify the same type and kind type parameters. Ctt20 If any ultimate specification of a deferred constant is of a non-implied rank R, then an explicit specification of that deferred constant shall have rank R, and all other ultimate specifications of that deferred constant shall either have implied rank or have rank R. Ctt21 If any ultimate specification of a deferred constant has explicit shape S, then an explicit specification of that deferred constant shall have shape S, and all other ultimate specifications of that deferred constant shall have implied rank, implied shape, or shape S. If any ultimate specification of a deferred constant has an explicit shape S, then that deferred constant has shape S. Otherwise, if any ultimate specification of that deferred constant has implied shape, then it has implied shape with the same rank. Otherwise it has implied rank. tt.2.2.4 Specification of deferred procedures Ctt22 If any ultimate specification of a deferred argument is a deferred procedure, then all ultimate specifications of that deferred argument shall be deferred procedure. Ctt23 Except for the PURE, SIMPLE, and ELEMENTAL attributes, the characteristics of all ultimate specifications of a deferred procedure shall be consistent. NOTE The characteristics of a procedure do not include the names of the dummy arguments, so they need not be the same. Ctt24 If any ultimate specification of a deferred procedure is SIMPLE, then an explicit specification of that deferred procedure shall be SIMPLE. Ctt25 If any ultimate specification of a deferred procedure is PURE, then an explicit specification of that deferred procedure shall be PURE or SIMPLE. Ctt26 If any ultimate specification of a deferred procedure is ELEMENTAL, then an explicit specification of that deferred procedure shall be ELEMENTAL. If any ultimate specification of a deferred procedure is SIMPLE then that deferred procedure is SIMPLE. Otherwise, if any ultimate specification of that deferred procedure is PURE, then it is PURE. If any ultimate specification of a deferred procedure is ELEMENTAL then that deferred procedure is ELEMENTAL. Only an explicit specification of a deferred procedure defines the names of its dummy arguments. The names of the dummy arguments of a deferred procedure without an explicit specification are unspecified. Ctt27 A deferred procedure shall not be referenced with keyword arguments unless it has an explicit specification. ===END===