--- ai12s/ai12-0212-1.txt 2018/10/19 05:59:55 1.17 +++ ai12s/ai12-0212-1.txt 2018/11/20 07:09:16 1.18 @@ -1,5 +1,7 @@ -!standard 4.3.5(0) 18-10-17 AI12-0212-1/07 +!standard 4.3.5(0) 18-11-19 AI12-0212-1/08 !class Amendment 16-12-27 +!status Amendment 1-2012 18-11-19 +!status ARG Approved 5-0-2 18-10-21 !status work item 17-06-10 !status received 16-06-12 !priority Low @@ -21,7 +23,7 @@ this now is to manually assemble a new container with a series of statements; but this has a number of issues: - - cannot be used in a subprogram contract (such as a post condition) + - cannot be used in a subprogram contract (such as a postcondition) - can make code harder to read since construction has to be moved to a separate function @@ -91,7 +93,7 @@ X : My_Set := [1, 2, 3]; - -- Equivalent to: + -- Equivalent to: X : My_Set := Empty_Set; Include (X, 1); Include (X, 2); @@ -113,17 +115,17 @@ Y : My_Set := [for Item of X => Item * 2]; - -- Equivalent to: + -- Equivalent to: Y : My_Set := Empty_Set; for Item of X loop Include (Y, Item * 2); end loop; -We may also wish to filter the items: +We may also wish to filter the items (not in this AI, see AI12-0250-1): Z : My_Set := [for Item of X when Item > 1 => Item - 1]; - -- Equivalent to: + -- Equivalent to: Z : My_Set := Empty_Set; for Item of X loop if Item > 1 then @@ -136,7 +138,7 @@ (note that this is not part of the current proposal): W : My_Set := [for A of X => - for B of X => A * B]; -- TBD: Not currently in this AI + for B of X => A * B]; -- Not proposed now (not in this AI) -- Equivalent to: W : My_Set := Empty_Set; @@ -169,7 +171,7 @@ either one finishes): V : My_Set := [for (A of X; I in 1..Max) => (A, I)]; - -- TBD: *Not* currently part of this AI + -- Not proposed now (not part of this AI) -- Equivalent to: V : My_Set := Empty_Set; @@ -177,17 +179,17 @@ Include (V, (A, I)); end loop; - -- where the parenthesized iterators run concurrently, with the iteration - -- stopping when either runs out of elements. + -- Where the parenthesized iterators run concurrently, with the iteration + -- stopping when either runs out of elements. The new aspect specifications for the set container would be: type Set is tagged private - with -- currently we have this: + with -- Ada 2012 have these: Constant_Indexing => Constant_Reference, Default_Iterator => Iterate, Iterator_Element => Element_Type, - -- this is new + -- This is new Aggregate => (Empty => Empty_Set, Add_Unnamed => Include); @@ -215,7 +217,7 @@ and have many of the same rules as array aggregates with respect to uniqueness of indices and full coverage. -So, to summarise: +So, to summarize: * New aspect on types specifying an empty default, plus an Add_Named procedure, or an Add_Unnamed procedure and/or an Assign_Indexed procedure (with a New_Indexed function to go with it). @@ -230,6 +232,30 @@ !wording +---- Wording for allowing square brackets as a syntax element: + +Modify 1.1.4(12): + +* A vertical line separates alternative items[ unless it occurs immediately + after an opening curly bracket, in which case it stands for itself]: + +Delete the second example (discrete_choice_list) in 1.1.4(13). + +Add after 1.1.4(13): + +* For symbols used in this notation (square brackets, curly brackets, and + the vertical line), the symbols when surrounded by ‘ represent themselves: + + discrete_choice_list ::= discrete_choice {'|' discrete_choice} + named_container_aggregate ::= '[' container_element_association_list ']' + +Add [ ] to the list of delimiters in 2.2(9/5). + +Replace "{|" with "{'|'" in 3.7.1(3), 3.8.1(4), 4.3.1(5), 4.4(3.1/3), +and 11.2(3). + +---- Wording to allow an aggregate as the entity denoted by an aspect: + Modify 13.1.1(5/3): An aspect_mark identifies an aspect of the entity defined by the @@ -243,6 +269,9 @@ an expression that is an aggregate, with the form of the aggregate determined by the identified aspect; + +---- Wording to add container aggregates as a type of aggregate: + Replace 4.3(2/5): aggregate ::= record_aggregate | extension_aggregate | array_aggregate @@ -271,14 +300,14 @@ (expression, expression {, expression}) | (expression {, expression}, others => expression) | (expression {, expression}, others => <>) - | [ expression{, expression}[, others => expression] ] - | [ expression{, expression}, others => <> ] - | [ ] + | '[' expression{, expression}[, others => expression] ']' + | '[' expression{, expression}, others => <> ']' + | '[' ']' Replace 4.3.3(4/5) with: named_array_aggregate ::= (array_component_association_list) - | [array_component_association_list] + | '['array_component_association_list']' Replace 4.3.3(5.1/5): @@ -302,7 +331,7 @@ array_component_association_list shall be iterated_component_associations with an iterator_specification. -Add 4.3.3(20) as follows: +Add before 4.3.3(21): For an array_aggregate that contains only array_component_associations that are iterated_component_associations with iterator_specifications, evaluation proceeds in two steps: @@ -318,7 +347,13 @@ the associated expression is evaluated, its value is converted to the component subtype of the array type, and used to define the value of the next component of the array starting at the low bound - and proceeding sequentially toward the high bound. + and proceeding sequentially toward the high bound. A check is made + that the second iteration results in the same array length; + Constraint_Error is raised if this check fails. + + AARM To Be Honest: Constraint_Error should be raised no later than + when the iterations exceed the expected array length; memory that + doesn't belong to the aggregate temporary should not be overwritten. Modify 4.3.3(21) as follows: @@ -333,7 +368,8 @@ corresponding index of the corresponding array component. {During an evaluation of the expression of an iterated_component_association with an iterator_specification, the value of the loop parameter - of the iterator_specification is the value produced by the iteration.} + of the iterator_specification is the value produced by the iteration + (as described in 5.5.2).} Add after 4.3.3(26): * For a named_array_aggregate containing only @@ -350,11 +386,25 @@ array type, bounds for each dimension are determined as for a positional_array_aggregate with zero expressions.} +Add after 4.3.3(31): + + Implementation Permissions + + When evaluating iterated_component_associations for an array_aggregate + that contains only iterated_component_associations with + iterator_specifications, the first step of evaluating a + iterated_component_association can be omitted if the implementation can + determine the number of values by some other means. + + AARM Discussion: For instance, if the type of the aggregate is constrained, + the implementation can (but does not have to) calculate the expected length + from the constraint. + Replace 4.3.4(4/5) with: array_delta_aggregate ::= (base_expression with delta array_component_association_list) - | [base_expression with delta array_component_association_list] + | '['base_expression with delta array_component_association_list']' ---- end of wording for array [delta] aggregate enhancement ---- @@ -435,11 +485,11 @@ container_aggregate ::= null_container_aggregate | positional_container_aggregate | named_container_aggregate - null_container_aggregate ::= [ ] + null_container_aggregate ::= '[' ']' - positional_container_aggregate ::= [ expression{, expression} ] + positional_container_aggregate ::= '[' expression{, expression} ']' - named_container_aggregate ::= [ container_element_association_list ] + named_container_aggregate ::= '[' container_element_association_list ']' container_element_association_list ::= container_element_association {, container_element_association} @@ -539,7 +589,7 @@ that is the sum of the position number of the lower bound and one less than the number of expressions in the aggregate; * if the aggregate is a named_container_aggregate, the lower bound - is the lowest value covered by a key_choice_list or as the low + is the lowest value covered by a key_choice_list or is the low bound of a range defined by a discrete_subtype_definition of a loop_parameter_specification; the upper bound is the highest value covered by a key_choice_list or is the high bound of a @@ -547,14 +597,14 @@ loop_parameter_specification. * if the aggregate is not an indexed aggregate, by assignment from the Empty constant, or from a call on the Empty function specified in - the Aggregate aspect. In the case of an Empty function with a formal + the Aggregate aspect. In the case of an Empty function with a formal parameter, the actual parameter has the following value: * for a null_container_aggregate, the value zero; * for a positional_container_aggregate, the number of expressions; * for a named_container_aggregate without an iterated_element_association, the number of /key_/expressions; * for a named_container_aggregate where every iterated_element_association - is of the form with a loop_parameter_specification, the total + contains a loop_parameter_specification, the total number of elements specified by all of the container_element_associations; * otherwise, to an implementation-defined value. @@ -587,8 +637,9 @@ the value from the key_choice as the second parameter, and the result of evaluating the expression as the third parameter; * for a container_element_association with an iterated_element_association, - the iterated_element_association is elaborated, and an iteration - is performed, and for each value of the loop parameter of the + the iterated_element_association is elaborated, then an iteration + is performed as described in 5.5 or 5.5.2, and for each value of the + loop parameter of the iteration the Add_Named procedure is invoked with the anonymous object A as the first parameter, the result of evaluating the expression as the third parameter, and: @@ -605,8 +656,9 @@ * for any other named_container_aggregate, the container_element_associations (which are necessarily iterated_element_associations) are evaluated in the order given: - * the iterated_element_association is elaborated, and an iteration - is performed, and for each value of the loop parameter of the + * the iterated_element_association is elaborated, then an iteration + is performed as described in 5.5 or 5.5.2, and for each value + of the loop parameter of the iteration, the Add_Unnamed procedure is invoked, with the anonymous object A as the first parameter and the result of evaluating the expression as the second parameter. @@ -778,7 +830,7 @@ end loop; -- The above could have been written using an explicit key_expression: - M := [for Key of Keys, Key => Integer'Image (Key)]; + M := [for Key of Keys use Key => Integer'Image (Key)]; -- Example aggregates using Vector_Type V : Vector_Type; @@ -3691,6 +3743,100 @@ hours of possible work time between the end of this meeting and the time we're supposed to deliver the RM -- and I don't know yet how much of that time will be funded. I probably already have work to use much of it in any case.) + +**************************************************************** + +From: Randy Brukardt +Sent: Tuesday, November 20, 2018 1:05 AM + +Jeff had sent some comments: + +>!problem +>“post condition” -> postcondition. + +Yup. + +>!proposal +>Normally (but not always) we capitalise the first letter of a comment in +>examples. + +Yup. I got rid of the TBD parts of the comments, as we're not currently +thinking about any of these other ideas. I changed those to "Not proposed +now (not in this AI)". + +Also, there is a filter example. I changed that to refer to AI12-0250-1 +and to make it clear that it too is not in this AI. + +>!wording +>Presumably “Add 4.3.3(20)” should be “Add after 4.3.3(20)” as there already +>is a 4.3.3(20). + +Well, it really is "Add before 4.3.3(21)" because it needs to be under the +Dynamic Semantics heading. + +>And as sent previously: +> +>4.3.5 +> +>Dynamic Semantics +>3rd bullet – “as the low bound of a range” -> “is the low bound of a range”? + +The upper bound uses similar wording using "is", so I think "as" is just a typo. + +>8th bullet (for a named_container_aggregate) – “is of the form with” – +>I don’t find this terribly clear, though maybe just changing “with” to +>“containing” would suffice. + +I just got rid of the whole mess replacing it with "containing". (Why the +"is of the form"? It either contains a loop_parameter_specification or it +doesn't, and we're already talking syntactally.) + +This leaves us with: + + * for a named_container_aggregate where every iterated_element_association + contains a loop_parameter_specification, ... + +>15th (for a container_element_association) and final (the +>iterated_element_association) bullets – both of these have two “and”s – +>maybe the first “and” should go, and/or possibly the second “and” +>should be a “then”?? + +I thought it was the first "and" that should be replaced by a "then". The +individual loop parameter values are those generated by the iteration (thus +the "and"). But really the phrase "then an iteration is performed" (originally +"and an iteration is performed") is very vague. I think we need to say +something about how an iteration is performed. Obviously we don't want to say +any more than absolutely required. Perhaps something like "then an iteration +is performed as described in 5.5 or 5.5.2"? That's what I used, at least (and +similarly in the 4.3.3(23.2/3) wording). + +---- + +I was directed to add a rule that the meta-symbols in the grammar notation +stood for themselves if surrounded in single quotes, and delete the old hack. +I also added the missing definition of the square bracket delimiters. This +resulted in the following additional wording: + +>Modify 1.1.4(12): +> +>* A vertical line separates alternative items[ unless it occurs +>immediately +> after an opening curly bracket, in which case it stands for itself]: +> +>Delete the second example (discrete_choice_list) in 1.1.4(13). +> +>Add after 1.1.4(13): +> +>* For symbols used in this notation (square brackets, curly brackets, and +> the vertical line), the symbols when surrounded by ' represent themselves: +> +> discrete_choice_list ::= discrete_choice {'|' discrete_choice} +> named_container_aggregate ::= '[' container_element_association_list ']' +> +>Add [ ] to the list of delimiters in 2.2(9/5). +> +>Replace "{|" with "{'|'" in 3.7.1(3), 3.8.1(4), 4.3.1(5), 4.4(3.1/3), +>and 11.2(3). ****************************************************************

Questions? Ask the ACAA Technical Agent