--- ai05s/ai05-0158-1.txt 2009/11/03 00:12:17 1.4 +++ ai05s/ai05-0158-1.txt 2009/11/03 00:19:50 1.5 @@ -1,4 +1,5 @@ -!standard 4.4 (3) 09-11-01 AI05-0158-1/02 +!standard 3.8.1(5) 09-11-02 AI05-0158-1/03 +!standard 4.4(3) !standard 4.5.2(3) !standard 4.5.2(27) !class Amendment 09-06-07 @@ -20,37 +21,53 @@ pre- and post-conditions become widely used. If the values of A, B,and C are contiguous values of some discrete type, the expression can be written as a membership operation: (X in A..C) . Otherwise this syntactic -shortcut is not available. We propose a simple extension of the syntax of -membership operations, so that the right operand can specify a subset of values -of some type. +shortcut is not available. Memberships should be more flexible. !proposal -Extend the syntax of memberships as shown in the wording. +We propose a simple extension of the syntax of +membership operations, so that the right operand can specify a subset of values +of some type. We propose a simple extension of the syntax of +membership operations, so that the right operand can specify a subset of values +of some type. The type does not need to be discrete, and the choices do not +need to be static, so that one can write: + +if C not in 'A' | 'B' | 'O' then Put_Line ("invalid blood type"); else .. + +while Name (1 .. N) in T.Element (X) | T.Element (Y) | T.Element (Z) loop ... !wording +Modify 3.8.1 (5) as follows: + + discrete_Choice ::= choice_expression | discrete_Range | others + Modify 4.4(3) as follows: - restricted_expression := - restricted_relation {logical_operator restricted_relation} - logical_operator ::= and | and then | or | or else | xor + expression := relation {logical_operator relation} - restricted_relation ::= + choice_expression := + choice_relation {logical_operator choice_relation} + + + choice_relation ::= simple_expression [relational_operator simple_expression] relation ::= simple_expression [not] in choice_list - choice_list ::= choice {'|' choice} - choice ::= restricted_expression | range | subtype_mark + + membership_choice_list ::= membership_choice {'|' membership_choice} -[modify the production for discrete_choice in 3.8.1 (5) accordingly] + membership_choice ::= choice_expression | range | subtype_mark + logical_operator ::= and | and then | or | or else | xor + + Add after 4.5.2(3): (Name Resolution Rules) -If the choice_list in a membership operation has more that one choice, then -all choices must have a single common type, which is the tested type of the -operation. +If the membership_choice_list in a membership operation has more that one +choice, then all choices must have a single common type, which is the tested +type of the operation. Modify 4.5.2(27) as follows: @@ -82,6 +99,8 @@ !example +(See proposal.) + !ACATS test Add an ACATS test for this new feature. @@ -556,5 +575,68 @@ The new syntax is unambiguous, and presents a minuscule incompatibility with Ada2005. [Editor's note: This is version /02 of the AI.] + +**************************************************************** + +From: Tucker Taft +Date: Sunday, November 1, 2009 11:13 AM + +It would help to have some examples. + +Also, rather than using "restricted_*" where "restricted" +is somewhat mysterious, how about: + + choice_expression ::= + choice_relation ... + +also, rather than using simply "choice_list" and "choice" how about "membership_choice_list" and "membership_choice" to distinguish it from the other kinds of choices? Hence: + + choice_expression ::= + choice_relation {logical_operator choice_relation} + + choice_relation ::= + simple_expression [relational_operator] simple_expression + + relation ::= choice_relation | + simple_expression [not] in membership_choice_list + + membership_choice_list ::= + membership_choice { '|' membership_choice } + + membership_choice ::= choice_expression | range | subtype_mark + +... + + discrete_choice ::= choice_expression | discrete_range | OTHERS + +... + + expression ::= relation {logical_operator relation} + + logical_operator ::= AND | AND THEN | OR | OR ELSE | XOR + +**************************************************************** + +From: Ed Schonberg +Date: Monday, November 2, 2009 1:25 PM + +Good points all. Here is updated version: + +[Editor's note: This is version /03 of the AI.] + +**************************************************************** + +From: Tucker Taft +Date: Monday, November 2, 2009 1:43 PM + +The wording still talks about "choice_list" but the syntax now uses +"membership_choice_list". + +**************************************************************** + +From: Randy Brukardt +Date: Monday, November 2, 2009 1:48 PM + +I'll fix it when I post it. [And I did - ED] ****************************************************************

Questions? Ask the ACAA Technical Agent