To: J3 J3/25-139 From: generics Subject: Edits for TEMPLATES: Consistency of deferred args Date: 2025-May-19 References: 25-108, 25-135, 25-136, 25-137, 25-138, 24-125r5, 24-126r4, 24-127r4 Introduction: ============= This is the 5th 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-138. tt.8.2 Consistency of deferred argument specifications tt.8.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.8.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 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) ! Instantiation arg associated with U can be any non-abstract type. DEFERRED TYPE :: U END REQUIREMENT REQUIREMENT R_EXTENSIBLE(U) ! Instantiation arg associated with U has to be extensible ! (e.g., cannot be intrinsic), and cannot be abstract. DEFERRED TYPE, EXTENSIBLE :: U END REQUIREMENT REQUIREMENT R_ABSTRACT(U) ! Instantiation arg associated with U has to be extensible, ! and can be abstract. DEFERRED TYPE, ABSTRACT :: U END REQUIREMENT Given the requirements above and deferred arguments T1, T2, ..., T15, the following lines are valid or invalid as marked. REQUIRE R_REGULAR(T1) ! Valid, non-extensible REQUIRE R_EXTENSIBLE(T2) ! Valid, extensible, non-abstract REQUIRE R_ABSTRACT(T3) ! Valid, abstract ! Valid: T4 is specified to be non-extensible. DEFERRED TYPE :: T4 ! Declares T4 to be non-extensible REQUIRE R_REGULAR(T4) ! Req. T4 to be non-abstract ! Invalid DEFERRED TYPE :: T5 ! Declares T5 to be non-extensible REQUIRE R_EXTENSIBLE(T5) ! Req. T5 to be extensible, non-abstract ! Invalid DEFERRED TYPE :: T6 ! Declares T6 to be non-extensible REQUIRE R_ABSTRACT(T6) ! Req. T6 to be extensible ! Valid: T7 is specified to be extensible, non-abstract DEFERRED TYPE, EXTENSIBLE :: T7 ! Declares T7 to be extensible REQUIRE R_REGULAR(T7) ! Req. T7 to be non-abstract ! Valid: T8 is specified to be extensible, non-abstract DEFERRED TYPE, EXTENSIBLE :: T8 ! Declares T8 to be extensible REQUIRE R_EXTENSIBLE(T8) ! Req. T8 to be extensible, non-abstract ! Valid: T9 is specified to be extensible, non-abstract DEFERRED TYPE, EXTENSIBLE :: T9 ! Declares T9 to be extensible REQUIRE R_ABSTRACT(T9) ! Req. T9 to be extensible ! Invalid DEFERRED TYPE, ABSTRACT :: T10 ! Declares T10 to be abstract REQUIRE R_REGULAR(T10) ! Req. T10 to be non-abstract ! Invalid DEFERRED TYPE, ABSTRACT :: T11 ! Declares T11 to be abstract REQUIRE R_EXTENSIBLE(T11) ! Req. T11 to non-abstract ! Valid: specification of T12 to be abstract DEFERRED TYPE, ABSTRACT :: T12 ! Declares T12 to be abstract REQUIRE R_ABSTRACT(T12) ! Req. T12 to be extensible ! Valid: specification of T13 to be extensible, non-abstract REQUIRE R_REGULAR(T13) ! Req. T13 to be non-abstract REQUIRE R_EXTENSIBLE(T13) ! Req. T13 to be extensible, non-abstract ! Valid: specification of T14 to be extensible, non-abstract REQUIRE R_REGULAR(T14) ! Req. T14 to be non-abstract REQUIRE R_ABSTRACT(T14) ! Req. T14 to be extensible ! Valid: specification of T15 is extensible, non-abstract REQUIRE R_EXTENSIBLE(T15) ! Req. T15 to be extensible, non-abstract REQUIRE R_ABSTRACT(T15) ! Req. T15 to be extensible tt.8.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.8.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===