!standard 4.3.4(26/5) 20-06-01 AI12-0379-1/02 !standard 4.3.4(30/5) !standard 4.3.5(66/5) !standard 4.3.5(67/5) !standard 4.3.5(68/5) !standard 4.3.5(69/5) !standard 4.3.5(70/5) !standard 4.3.5(71/5) !standard 4.3.5(72/5) !standard 4.3.5(73/5) !standard 4.3.5(74/5) !standard 4.3.5(84/5) !standard 4.3.5(90/5) !standard 4.3.5(91/5) !standard 4.5.10(41/5) !standard 4.5.10(43/5) !standard 5.2.1(6/5) !standard 5.5.3(31/5) !class presentation 20-05-26 !status Amendment 1-2012 20-05-26 !status work item 20-05-26 !status received 20-05-26 !priority Low !difficulty Easy !qualifier Omission !subject More Presentation issues !summary [Editor's note: These changes are included in the current draft of the Standard, even though they are not yet approved.] (1) Remove "* 2" from the example 4.3.5(84/5). (2) Replace "Link" with "Head" in 4.3.4(26/5). (3) Replace "Float" with "Real" in 4.3.4(30/5). (4) Add ".all" in 4.3.5(90-1/5). (5) Remove the private part 4.3.5(66-74/5). (6) Add an additional ')' to 4.5.10(41/5). (7) Add conversions for Number_of_Stemps to 4.5.10(43/5). (8) The literal in 5.2.1(6/5) is the real literal 1.0. (9) The final call in 5.5.3(31/5) should be My_Map.Iterate. !question (1) 4.3.5(83-4/5) says: -- A set aggregate consisting of two iterated_element_associations: S := [for Item in 1 .. 5 => Item, for Item in 1 .. 5 => -Item]; -- Is equivalent (assuming set semantics) to: S := Empty_Set; for Item in -5 .. 5 loop if Item /= 0 then Include (S, Item * 2); end if; end loop; The "* 2" does not make sense in the equivalence here. Should it be deleted? (Yes.) (2) 4.3.4(26/5) says: New_Cell : Cell := (Min_Cell (Link) with delta Value => 42); -- see 3.10.1 for Cell and Link; 6.1 for Min_Cell But "Link" is a type; it can't be passed as a parameter to function Min_Cell. Should this be something else? (Yes.) (3) Type Point has components of type Real, while the parameters to Translate in 4.3.4(30/5) have type Float. "+" will not work with this type mismatch. Should one of the types be changed? (Yes.) (4) Type Pair has a Value component that is access-to-constant String. 4.3.5(90-1/5) use the Value component as a parameter to Add_to_Map, which takes a String parameter. Should a dereference be added? (Yes.) (5) Type Vector_Type at 4.3.5(74/5) is a tagged type; does it need a type extension? (Yes.) (6) 4.5.10(41.5) has three open parens and only two closing parens. Should an additional closing paren be added? (Yes.) (7) 4.5.10(43/5) contains "1.0 / Number_of_Steps" (twice), but Number_of_Steps is a Natural value. This subexpression cannot resolve, so should type conversions be added? (Yes.) (8) 5.2.1(6/5) uses Board, which is of type Matrix, whose components are type Real. The literal in this example, however, is an integer literal. Should this be changed to a real literal? (Yes.) (9) 5.5.3(29/5) shows a call to My_Map.Iterate, while 5.5.3(31/5) shows a call to My_Map.Iterator. These should be the same, right? (Yes.) !response (1) This looks like a cut-and-paste of the previous example with insufficient editing. (2) It looks like "Head" (an object) was intended here. (3) Translate should have Real parameters. (4) Yes, a dereference is needed. (5) Yes, an extension would be needed here. But a more important question is why this private part is given at all -- it just confuses the example (which is of container aggregates). That's especially true of type Set_Type for which the full type has it's own aggregates. It makes more sense to omit the private part altogether so that the example concentrates on container aggregates. (6) The number of parens needs to be balanced. (7) These conversions make the expression unreadable because of the need for an additional line break in the middle of the denominator. However, since Number_of_Steps has to be an integer for this algorithm, we can't change it's type. (8) This definitely needs to be a real literal. (9) Iterate is defined in A.18.4, so that is the name that should be used in this example. (The example is wrong in the original AI, which is WG 9-approved so it can't be changed anymore.) !wording (1) Replace 4.3.5(84/5) with: -- Is equivalent (assuming set semantics) to: S := Empty_Set; for Item in -5 .. 5 loop if Item /= 0 then Include (S, Item); end if; end loop; (2) Replace 4.3.4(26/5) with: New_Cell : Cell := (Min_Cell (Head) with delta Value => 42); -- see 3.10.1 for Cell and Head; 6.1 for Min_Cell (3) Replace 4.3.4(30/5) with: function Translate (P : Point'Class; X, Y : Real) return Point'Class is (P with delta X => P.X + X, Y => P.Y + Y); -- see 3.9 for declaration of type Point (4) Replace 4.3.5(90-1/5) with: -- A map aggregate using an iterated_element_association -- and a key_expression, built from from a table of key/value pairs: M := [for P of Table use P.Key => P.Value.all]; -- Is equivalent to: M := Empty_Map; for P of Table loop Add_To_Map (M, P.Key, P.Value.all); end loop; (5) Replace 4.3.5(66-74/5) with: -- Private part not shown. (6) Replace 4.5.10(41/5) with: Put_Line ("Sum of Squares is" & Integer'Image([for I in 1 .. 10 => I**2]'Reduce("+", 0))); (7) Replace 4.5.10(43/5) with: -- See 3.5.7. function Pi (Number_Of_Steps : Natural := 10_000) return Real is (1.0 / Real (Number_Of_Steps) * [for I in 1 .. Natural (Number_Of_Steps) => (4.0 / (1.0 + ((Real (I) - 0.5) * (1.0 / Real (Number_Of_Steps)))**2))] 'Reduce("+", 0.0)); (8) Replace 5.2.1(6/5) with: Board(1, 1) := @ + 1.0; -- An abbreviation for Board(1, 1) := Board(1, 1) + 1.0; (9) Modify part of 5.5.3(31/5): My_Map.[Iterator]{Iterate} (P'Access); !corrigendum 4.3.4(0) @dinsc See the conflict file for the changes. !corrigendum 4.3.5(0) @dinsc See the conflict file for the changes. !corrigendum 4.5.10(0) @dinsc See the conflict file for the changes. !corrigendum 5.2.1(0) @dinsc See the conflict file for the changes. !corrigendum 5.5.3(0) @dinsc See the conflict file for the changes. !ASIS No ASIS effect. !ACATS test No ACATS tests needed for presentation issues. !appendix From: Christoph Grein Sent: Monday, May 25, 2020 4:08 AM !topic Error in example !reference Ada 202x RM4.3.5(83/5,84/5) !from Christoph Grein 2020-05-25 !discussion -- A set aggregate consisting of two iterated_element_associations: S := [for Item in 1 .. 5 => Item, for Item in 1 .. 5 => -Item]; -- Is equivalent (assuming set semantics) to: S := Empty_Set; for Item in -5 .. 5 loop if Item /= 0 then Include (S, Item * 2); end if; end loop; The red part {"* 2" was in red - editor} is wrong and must be removed. (The proposed notation for comment submissions using brackets for text to be omitted would be misleading here Include (S, Item[ * 2]);) I think the result is [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5] **************************************************************** From: Randy Brukardt Sent: Tuesday, May 26, 2020 3:35 PM This appears in every version going back to the point when the filter examples were removed to a separate AI. Looks like a cut-and-paste error at that point. Anyway, put it into a presentation AI and fixed it in the draft RM. Thanks for pointing it out. **************************************************************** [The following is a series of private comments on the examples in the draft RM, and my responses. - Editor.] > 4.3.4 Delta Aggregates > > Link as defined in 3.10.1 is a type which is not suitable in the usage > below: > 26/5 New_Cell : Cell := (Min_Cell ( Link ) with delta Value => 42); > -- see 3.10.1 for Cell and Link; 6.1 for Min_Cell Looks like it should have been Head. > Point components are > of type Real so should be also Translate parameters to avoid error on > operator "+": > >30/5 function Translate (P : Point'Class; X, Y : Real ) return Point'Class is > ( (P with delta X => P.X + X, > Y => P.Y + Y) ) ; -- see 3.9 Yes, thanks. >§ 4.3.5 Container Aggregates > >The full declaration should have an extension: >74/5 type Vector_Type is new String_Vectors.Vector with null record ; OK. >As Set_Type is new Bit_Vector type an array of Boolean values, ... No, it is a private type with a user-defined aggregate. Consider all of these examples outside of the package body. I don't think the private part of this example should even be here, as it has nothing to do with the example other than showing how it might be implemented. It's obviously confusing, so I will propose to delete it. > As Value component is of access constant String type, .all should be added > to Value: > 90/5 -- A map aggregate using an iterated_element_association > -- and a key_expression, built from from a table of key/value pairs: > M := [for P of Table use P.Key => P.Value .all ]; > 91/5 -- Is equivalent to: > M := Empty_Map; > for P of Table loop > Add_To_Map (M, P.Key, P.Value .all ); > end loop; OK. >§ 4.5.2 Relational Operators and Membership Tests > >There is a missing record keyword before Data declaration: >30.c/5 type Root is tagged null record; > type Ext is new Root with record Data : Integer; end record; Got it. This is just fixed without appearing in any AI. >§ 4.5.10 Reduction Expressions > >There is a missing ) ending Put_Line: >41/5 Put_Line ("Sum of Squares is" & > Integer'Image([for I in 1 .. 10 => I**2]'Reduce("+", 0)) ) ; OK. >Number_Of_Steps should be also convert into Real type: >43/5 -- See 3.5.7. > function Pi (Number_Of_Steps : Natural := 10_000) return Real is > (1.0 / Real ( Number_Of_Steps ) * > [for I in 1 .. Number_Of_Steps => > (4.0 / (1.0 + ((Real (I) - 0.5) * (1.0 / Real ( Number_Of_Steps ) ))**2))] > 'Reduce("+", 0.0)) OK. ****************************************************************