Version 1.1 of ai05s/ai05-0158-1.txt

Unformatted version of ai05s/ai05-0158-1.txt version 1.1
Other versions for file ai05s/ai05-0158-1.txt

!standard 4.4 (3)          09-06-07 AI05-0158-1/01
!standard 4.5.2(3)
!standard 4.5.2(30/2)
!class Amendment 09-06-07
!status work item 09-06-07
!status received 09-03-30
!priority Low
!difficulty Medium
!subject Generalizing membership tests
!summary
Extend the syntax of membership tests to simplify complex conditions that can be expressed as membership in a subset of values of any type.
!problem
Conditions of the form (X = A) or else (X = B) or else (X = C) where A, B, C are of some arbitrary type are common, and will be more frequent when 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.
!proposal
Extend the syntax of memberships as shown in the wording.
!wording
Modify 4.4(3) as follows:
relation ::= simple_expression [not] in choice_list choice_list ::= choice {'|' choice} choice ::= simple_expression | range | subtype_mark
[Editor's comment: This grammer is ambiguous if the expression is used in a discrete_choice_list (that is, in a variant part, case statement, or array aggregate. How that is going to be addressed needs to be described.]
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.
Add somewhere in 4.5.2(28-31): (Dynamic Semantics)
The left operand is elaborated first. If the choice_list has more that one choice, the operation is equivalent to a short-circuit sequence of tests : if a choice is a simple expression the corresponding test is an equality operation, otherwise it is a membership test whose right operand is the corresponding range or subtype_mark.
[Editor's comment: The first sentence contradicts 4.5.2(27). Is that really what we want? We ought to reword this to fit in with the existing wording.]
!discussion
!example
!ACATS test
Add an ACATS test for this new feature.
!appendix

****************************************************************

Questions? Ask the ACAA Technical Agent