Version 1.1 of ai12s/ai12-0403-1.txt
!standard 4.2.1(15/5) 20-10-15 AI12-0403-1/01
!standard 4.2.1(17/5)
!standard 4.2.1(18/5)
!standard 4.2.1(19/5)
!standard 4.3.5(93/5)
!class binding interpretation 20-10-15
!status work item 20-10-15
!status received 20-10-15
!priority Low
!difficulty Easy
!qualifier Omission
!subject Presentation issues from Draft 26 review
!summary
Various presentation issues were noted by reviewers of Draft 26.
!question
(1) In 4.3.5(93/5), "Add_Positional" is not defined; it should
be "Append_One", right? (Yes.)
(2) In 4.2.1(17/5), we have
function To_Roman_Number (S : String) return Roman_Number
But this function needs to have a parameter of Wide_Wide_String to
meet the requirements on the profile of a String_Literal function,
right? (Yes.)
[Editor's note: More issues to be added here.]
!recommendation
(1) Fix as suggested.
(2) Add "Wide_Wide_" in a number of places, and reformat as needed.
[Editor's note: More issues to be added here.]
!wording
Modify 4.2.1(15/5-20/5):
subtype Roman_Character is {Wide_Wide_}Character
with Static_Predicate =>
Roman_Character in 'I' | 'V' | 'X' | 'L' | 'C' | 'D' | 'M';
Max_Roman_Number : constant := 3_999; --
type Roman_Number is range 1 .. Max_Roman_Number
with String_Literal => To_Roman_Number;
function To_Roman_Number (S : {Wide_Wide_}String) return Roman_Number
with Pre => S'Length > 0 and then
(for all Char of S => Char in Roman_Character);
function To_Roman_Number (S : {Wide_Wide_}String) return Roman_Number is
(declare
R : constant array (Integer range <>) of Roman_Number :=
(for D in S'range => Roman_Digit'Enum_Rep
(Roman_Digit'{Wide_Wide_}Value (''' & S(D) & '''))); --
begin
[for I in R'range =>
(if I < R'Last and then R(I) < R(I + 1) then -1 else 1) * R(I)]
'Reduce("+", 0)
);
X : Roman_Number := "III" * "IV" * "XII"; --
Modify 4.3.5(93/5):
-- Is equivalent to:
V := Empty_Vector (<estimate of size of M>); for Elem of M loop
[Add_Positional]{Append_One} (V, Elem); end loop;
!discussion
!ASIS
No ASIS effect.
!ACATS test
!appendix
!topic Wrong profile in 4.2.1 Examples
!reference Ada 202x RM4.2.1(18/5,19/5)
!from Max Reznik 20-09-14
!keywords User-Defined String Literal Wide_Wide_String
!discussion
In ARM 202x Draft 26 "4.2.1 User-Defined Literals" there is an example:
function To_Roman_Number (S : String) return Roman_Number
But its profile is incorrect, because, according to the rules above,
the parameter should have Wide_Wide_String type.
****************************************************************
!topic Wrong profile in 4.2.1 Examples
!reference Ada 202x RM4.2.1(18/5,19/5)
!from Max Reznik 20-09-14
!keywords User-Defined String Literal Wide_Wide_String !discussion
In ARM 202x Draft 26 "4.2.1 User-Defined Literals" there is an example:
function To_Roman_Number (S : String) return Roman_Number
But its profile is incorrect, because, according to the rules above, the
parameter should have Wide_Wide_String type.
****************************************************************
From: Christoph Grein
Sent: Wednesday, September 23, 2020 7:35 AM
There is more wrong:
In (19/5) Reduce("+", 0), zero does not belong to the subtype Roman_Number,
so it's illegal.
****************************************************************
From: Christoph Grein
Sent: Wednesday, September 23, 2020 7:59 AM
Oh, and also negative numbers are not in range, so also this is illegal:
(if I < R'Last and then R(I) < R(I + 1) then -1 else 1) * R(I)]
****************************************************************
From: Christoph Grein
Sent: Saturday, October 3, 2020 5:24 AM
Hm, I withdraw my claims about the initial value 0 and factor -1 being
illegal. value_type and accum_type are Roman_Number'Base, a subtype of the
type of Roman_Number.
****************************************************************
From: Tucker Taft
Sent: Monday, October 5, 2020 9:21 AM
In 4.3.5(93/5), the example should be fixed as follows:
-- Is equivalent to:
V := Empty_Vector (<estimate of size of M>); for Elem of M loop
[Add_Positional]{Append_One} (V, Elem); end loop;
****************************************************************
Questions? Ask the ACAA Technical Agent