From 085bd1e3681fc350413a90a4806f7284af500ccf Mon Sep 17 00:00:00 2001 From: Aury Shafran Date: Wed, 13 Nov 2024 11:22:38 -0800 Subject: [PATCH] Rework instantiation args --- J3-Papers/edits/24-164_instantiate.txt | 194 ++++++++++++------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/J3-Papers/edits/24-164_instantiate.txt b/J3-Papers/edits/24-164_instantiate.txt index c6fdac1..aa9753e 100644 --- a/J3-Papers/edits/24-164_instantiate.txt +++ b/J3-Papers/edits/24-164_instantiate.txt @@ -10,11 +10,6 @@ Introduction: This is the 4th of 6 papers that provide edits for the approved syntax for templates. -{ UTI: Can we enable I/O generic spec as an instantiation argument? - - instantiate foo(..., write(formatted)) -} - { UTI: Prevent circular dependencies in deferred procedure args } Section 1: @@ -192,70 +187,80 @@ REQUIRE statement, or by inline instantiation. R1528 <> [ = ] -C1542 (R1528) Each shall be the name of a deferred argument in - the referenced requirement or template. - -In the absence of an argument keyword, an instantiation argument -corresponds to the deferred argument occupying the corresponding -position in ; that is, the first instantiation -argument corresponds to the first deferred argument in the -reduced list, the second instantiation argument corresponds to the -second deferred argument in the reduced list, etc. - R1529 <> <> <> - <> + <> + +C1542a (R1528) The = shall not be omitted from an + unless it has been omitted from + each preceding in the argument + list. + +C1542b (R1528) Each shall be the name of a deferred argument in + the referenced requirement or template. + +The instantiation argument list identifies the correspondence between the +instantiation arguments and the deferred arguments of the referenced +templated or requirement. This correspondence can be established either by +keyword or by position. If an argument keyword appears, the instantiation +argument corresponds to the deferred argument whose name is the same as +the argument keyword. In the absence of an argument keyword, an +instantiation argument corresponds to the deferred argument occupying the +corresponding position in the deferred argument list; that is, the first +instantiation argument corresponds to the first deferred argument in the +deferred argument list, the second instantiation instantiation argument +corresponds to the second deferred argument, etc. Each instantiation +argument shall correspond to a deferred argument, and exactly one +instantiation argument shall correspond to each deferred argument. + +The entity that is associated with a deferred argument is called its +effective instantiation argument. -C1542b (R1529) A shall not be . +15.6.4.2 Deferred type association -{UTI: - A defined I/O generic-spec cannot be used here because its - syntax of "READ(FORMATTED)", (and etc.) conflicts with other syntax. - E.g. that could be an array element reference, or a function - reference. We either need to say that defined I/O generics are not - permitted, provide separate syntax for it, or say that an - instantiation arg that is for a deferred procedure has special - behavior in that the READ(FORMATTED), etc., will always refer to - the defined I/O, not anything else it might possibly be. -} +C1543 (R1529) An that corresponds to a deferred type + shall be a . -15.6.4.2 Deferred type association +C1544 (R1529) A shall specify constant type parameters. + +C1545 (R1529) A shall not specify an abstract type if its + corresponding deferred type does not have the ABSTRACT + attribute. -C1543 (R1529) An that is a shall - correspond to a deferred argument that is a deferred type - in the referenced template or requirement. +{ Judging by C7109 & C7110, just saying "its corresponding deferred type" + should be sufficient and unambiguous in context. } -C1544 (R1529) An that is a shall have - constant type parameters. +C1546 (R1529) A shall specify an extensible derived type if + its corresponding deferred type has the EXTENSIBLE + attribute. -C1545 (R1529) An that corresponds to a deferred type - that does not have the ABSTRACT attribute shall not be - abstract. +C1547 (R1529) A shall specify a type for which a variable + of that type is permitted in a variable definition context. -C1546 (R1529) An , T, that corresponds to a deferred - type shall be a type for which a variable whose declared - type is T is permitted in a variable definition context. +{UTI: I don't think C1547 constraint works. "A variable of that type" + is too vague (e.g. what if this hypothetical variable has the INTENT(IN) + attribute?) and there are other ways for a variable to be permitted in + a variable definition context other than assignment (e.g. a EVENT_TYPE + can appear in a variable definition context in an EVENT POST statement).} NOTE 1 - Constraint C1545 ensures that intrinsic assignment is available for + Constraint C1547 ensures that intrinsic assignment is available for variables of deferred type. However, the constraint disallows some types, e.g., the EVENT_TYPE, from being used as an instantiation argument. -C1547 (R1529) An that corresponds to a deferred type - that has the EXTENSIBLE attribute shall be an extensible - derived type. - -C1548 (R1529) An that corresponds to a deferred - type shall not have a coarray potential subobject - component. +C1548 (R1529) A shall not specify a type with a coarray + potential subobject component. NOTE 2 Constraint C1548 avoids the possibility of assignment being invalid where the variable and expr do not agree on the allocation status of a coarray component. +A deferred type becomes associated with the type identified by its +corresponding instantiation argument. + NOTE 3 Non-abstract, extensible derived types can be associated with both abstract and non-extensible deferred type arguments. @@ -291,65 +296,60 @@ NOTE 4 15.6.4.3 Deferred constant association -C1549 (R1529) The shall be of type INTEGER, LOGICAL or - CHARACTER. +C1549 (R1529) An that corresponds to a deferred + constant shall be a . -C1550 (R1529) An that is a shall - correspond to a deferred argument that is a deferred constant - in the referenced template or requirement. +C1550 (R1529) The type and kind type parameters of shall + be the same as the type and kind type parameter of its + corresponding deferred constant. -C1551 (R1529) The type and kind of an that is a - shall have the same type and kind as the - corresponding deferred constant in the referenced template - or requirement. +{ The only permissible types for a deferred constant are INTEGER, LOGICAL, + or CHARACTER, so by C1551 those are the only permissible types for a + instantiation argument too. No extra constraint is + needed. } -C1552 (R1529) If the shape of the corresponding deferred constant in the - referenced template or requirement is not implied, then - the shall have the same shape. +C1551 (R1529) If the shape of the corresponding deferred constant is not + implied, then the shall have the same shape. -C1553 (R1529) If the rank of the corresponding deferred constant in the - referenced template or requirement is not implied, then - the shall have the same rank. +C1552 (R1529) If the rank of the corresponding deferred constant is not + implied, then the shall have the same rank. +The value of a deferred constant becomes associated with the value of +constant expression in the corresponding instantiation argument. 15.6.4.4 Deferred procedure association -C1554 (R1529) An that is a or - shall correspond to a deferred argument that - is a deferred procedure in the referenced template or - requirement. - -C1555 (R1529) An that is a shall - have the same characteristics as the corresponding - deferred procedure in the referenced template or - requirement, except that a pure instantiation argument may - be associated with a deferred argument that is not pure, a - simple instantiation argument may be associated with a - deferred argument that is not simple, and an elemental - instantiation argument may be associated with a deferred +C1553 (R1529) An that corresponds to a deferred + procedure shall be a or a . + +C1554 (R1529) A shall denote a nonintrinsic, nonpointer + procedure that has an explicit interface. + +{UTI: Add a constraint that shall not identify a +procedure with the same name as a generic identifer? Therefore, a name +which could be either would be interpreted as the generic identifier.} + +C1555 (R1529) The procedure specified by shall have the + same characteristics as its corresponding deferred + procedure, except that a pure procedure may correspond to a + deferred procedure that is not pure, a simple procedure may + correspond to a deferred procedure that is not simple, and + an elemental procedure may correspond to a deferred procedure that is not elemental. -C1556 An that is a shall be a - generic identifier with exactly one specific procedure that - has the same characteristics as the corresponding deferred - procedure of the referenced - template or requirement, except that a pure instantiation - argument may be associated with a deferred argument that - is not pure, a simple instantiation argument may be - associated with a deferred argument that is not simple, - and an elemental instantiation argument may be associated - with a deferred procedure that is not elemental. - -The deferred procedure is associated with the specific procedure that is -consistent with the characteristics. - -{UTI: This sentence is too vague. Perhaps this is better? - If an instantation argument is a generic identifier, the corresponding - deferred procedure is associated with the specific procedure of that - generic identifier that is consistent with the characteristics of the - deferred procedure. -We may also need to explicitly say what happens if the instantiation -argument is not a generic. And for that matter, say how association -happens for deferred constants and deferred types.} +C1556 (R1529) The generic identifier specified by shall + have exactly one specific procedure that has the same + characteristics as the corresponding deferred procedure, + except that a pure specific procedure may correspond to a + deferred procedure that is not pure, a simple specific + procedure may correspond to a deferred procedure that is not + simple, and an elemental specific procedure may correspond + to a deferred procedure that is not elemental. + +If a deferred procedure corresponds to a generic identifier, it becomes +associated with the specific procedure identified by constraint C1556. + +If a deferred procedure corresponds to a specific procedure name, it +becomes associated with that named procedure. ===END===