CVS difference for ai05s/ai05-0158-1.txt
--- ai05s/ai05-0158-1.txt 2010/12/15 00:10:58 1.12
+++ ai05s/ai05-0158-1.txt 2011/01/18 23:14:04 1.13
@@ -1,12 +1,15 @@
-!standard 3.8.1(5) 10-11-19 AI05-0158-1/07
+!standard 3.8.1(5) 11-01-17 AI05-0158-1/09
!standard 4.4(1)
!standard 4.4(2)
!standard 4.4(3)
-!standard 4.5.2(3)
+!standard 4.5.2(3/2)
!standard 4.5.2(4)
!standard 4.5.2(27)
!standard 4.5.2(28)
+!standard 4.5.2(29)
+!standard 4.5.2(30/2)
!standard 4.9(11)
+!standard 4.9(33)
!class Amendment 09-06-07
!status Amendment 2012 10-11-12
!status ARG Approved 9-0-1 10-10-29
@@ -18,9 +21,8 @@
!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. Introduce syntax
-for a list of expressions that may be used in loop contexts as well.
+The syntax of membership tests is extended to simplify complex conditions that
+can be expressed as membership in a subset of values of any type.
!problem
@@ -29,23 +31,14 @@
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. The type does not need to be discrete, and the choices do not
-need to be static, so that one can write:
+shortcut is not available.
-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 ...
-
!proposal
-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:
+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 ..
@@ -55,7 +48,7 @@
Replace 3.8.1 (5):
- discrete_Choice ::= choice_expression | discrete_Range | others
+ discrete_choice ::= choice_expression | discrete_range | others
Add categories choice_expression and choice_relation to the text
of 4.4(1/3) as modified by AI05-0147-1.
@@ -80,7 +73,7 @@
simple_expression [relational_operator simple_expression]
| simple_expression [not] in membership_choice_list
- membership_choice_list ::= membership_choice {'|' membership_choice}
+ membership_choice_list ::= membership_choice {| membership_choice}
membership_choice ::= choice_expression | range | subtype_mark
@@ -94,13 +87,12 @@
tested type.
with
-
- The tested type of a membership test is determined as follows:
- All elements of a membership choice list shall resolve to the same
- type, which is the tested type; or each element shall be of an
- elementary type, and the tested type shall be covered by by each of
- these elementary types.
+ The tested type of a membership test is determined by the membership_choices
+ of the membership_choice_list. Either all membership_choices of the
+ membership_choice_list shall resolve to the same type, which is the tested type;
+ or each membership_choice shall be of an elementary type, and the
+ tested type shall be covered by each of these elementary types.
If the tested type is tagged, then the simple_expression shall
resolve to be of a type that is convertible (see 4.6) to the tested
@@ -116,31 +108,36 @@
tested type of the membership test shall have a visible
primitive equality operator.
-Modify 4.5.2(27) as follows:
+Replace 4.5.2(27) with:
-If the choice_list has a single choice, the simple expression and the choice
-are elaborated in arbitrary order.
+For the evaluation of a membership test whose membership_choice_list has a single membership_choice,
+the simple_expression and the membership_choice are evaluated in arbitrary order.
-If the choice_list has more that one choice, the left operand is elaborated
-first and the operation is equivalent to a short-circuit sequence of
-individual tests on each choice.
+For the evaluation of a membership test whose membership_choice_list
+has more than one membership_choice, the left operand is evaluated first and the
+operation is equivalent to a sequence consisting of an individual test on each
+membership_choice combined with the short-circuit control form *or else*.
-Modify 4.5.2 (28) as follows:
+Replace 4.5.2(28) with:
A membership test using in yields the result True if any of the individual
-tests on the elements of the choice list yields True.
+tests on the membership_choices of the membership_choice_list yields True.
An individual membership test yields the result True if:
-* The choice is an expression, and the simple_expression is equal to the value
- of the choice. If the type of the expression is a record type or a limited
- type, the test uses the primitive equality for the type; otherwise the test
+* The membership_choice is a choice_expression, and the simple_expression is equal to
+ the value of the membership_choice. If the tested type is a record type or
+ a limited type, the test uses the primitive equality for the type; otherwise the test
uses predefined equality.
-* The choice is a range or subtype mark and:
+Modify 4.5.2(29) as follows:
-(followed by para. 29-30)
+* {The membership_choice is a range or subtype_mark, the}[The] tested type...
+Modify 4.5.2(30) as follows:
+
+* {The membership_choice is a subtype_mark, the}[The] tested type...
+
Replace 4.9(11) [definition of a static expression]
a membership test whose simple_expression is a static expression,
@@ -150,33 +147,34 @@
with
a membership test whose simple_expression is a static expression,
- and whose membership choice list consists of only static choice
- expressions, static ranges, and subtype marks each denoting
- a static [(scalar or string)] subtype;
+ and whose membership_choice_list consists only of membership_choices each of
+ which is either a static choice_expression, a static range, or a subtype_mark
+ that denotes a static [(scalar or string)] subtype;
+
-Append after 4.9(37/3) [another bulleted item in the definition of
- "statically unevaluated":
-
- - a choice_expression (or an expression of a range which occurs
- as a member of a membership_choice list) of a static membership
- test which is preceded in the enclosing membership_choice list by
- another item whose individual membership test (see 4.5.2)
+Append at the end of the bulleted list in the definition of
+"statically unevaluated" (4.9(33), added by AI05-0147-1):
+
+ - a choice_expression (or a simple_expression of a range which occurs
+ as a membership_choice of a membership_choice list) of a static
+ membership test which is preceded in the enclosing membership_choice
+ list by another item whose individual membership test (see 4.5.2)
statically yields True.
!discussion
The new syntax creates an upward incompatibility: a choice cannot be an
expression, as in Ada2005, but is limited to an expression without a
-membership operator. This is likely to be harmless, and seems to be preferable
+membership operator. This is likely to be harmless, and seems to be preferable
to making the grammar ambiguous, as shown in the following example, in which
a choice list can contain an arbitrary expression:
X : Boolean := ..
case X is
- when Y in 1..10 | 20 => -- ambiguous:
- -- could be (Y in 1..10) | 20
- -- which is otherwise type-incorrect
+ when Y in 1..10 | 20 => -- ambiguous:
+ -- could be (Y in 1..10) | 20
+ -- which is otherwise type-incorrect
Even though this is a contrived example, unlikely to show up in realistic
@@ -204,6 +202,172 @@
!ACATS test
Add an ACATS test for this new feature.
+
+!corrigendum 3.8.1(5)
+
+@drepl
+@xcode<@fa<discrete_choice ::= expression | discrete_range | >@ft<@b<others>>>
+@dby
+@xcode<@fa<discrete_choice ::= choice_expression | discrete_range | >@ft<@b<others>>>
+
+!corrigendum 4.4(1)
+
+@drepl
+An @i<expression> is a formula that defines the computation or retrieval of
+a value. In this International Standard, the term "expression" refers to a
+construct of the syntactic category @fa<expression> or of any of the other
+five syntactic categories defined below.
+@dby
+An @i<expression> is a formula that defines the computation or retrieval of
+a value. In this International Standard, the term "expression" refers to a
+construct of the syntactic category @fa<expression> or of any of the following
+categories: @fa<choice_expression>, @fa<choice_relation>, @fa<relation>,
+@fa<simple_expression>, @fa<term>, @fa<factor>, @fa<primary>, @fa<conditional_expression>,
+@fa<quantified_expression>.
+
+!corrigendum 4.4(2)
+
+@dinsa
+@xcode<@fa<expression ::=
+ relation {>@ft<@b<and>>@fa< relation} | relation {>@ft<@b<and then>>@fa< relation}
+ | relation {>@ft<@b<or>>@fa< relation} | relation {>@ft<@b<or else>>@fa< relation}
+ | relation {>@ft<@b<xor>>@fa< relation}>>
+@dinss
+@xcode<@fa<choice_expression ::=
+ choice_relation {>@ft<@b<and>>@fa< choice_relation}
+ | choice_relation {>@ft<@b<or>>@fa< choice_relation}
+ | choice_relation {>@ft<@b<xor>>@fa< choice_relation}
+ | choice_relation {>@ft<@b<and then>>@fa< choice_relation}
+ | choice_relation {>@ft<@b<or else>>@fa< choice_relation}>>
+
+@xcode<@fa<choice_relation ::=
+ simple_expression [relational_operator simple_expression]>>
+
+!corrigendum 4.4(3)
+
+@drepl
+@xcode<@fa<relation ::=
+ simple_expression [relational_operator simple_expression]
+ | simple_expression [>@ft<@b<not>>@fa<] >@ft<@b<in>>@fa< range
+ | simple_expression [>@ft<@b<not>>@fa<] >@ft<@b<in>>@fa< subtype_mark>>
+@dby
+@xcode<@fa<relation ::=
+ simple_expression [relational_operator simple_expression]
+ | simple_expression [>@ft<@b<not>>@fa<] >@ft<@b<in>>@fa< membership_choice_list>>
+
+@xcode<@fa<membership_choice_list ::= membership_choice {| membership_choice}>>
+
+@xcode<@fa<membership_choice ::= choice_expression | range | subtype_mark>>
+
+!corrigendum 4.5.2(3/2)
+
+@drepl
+The @i<tested type> of a membership test is the type of the range
+or the type determined by the @fa<subtype_mark>. If the tested type
+is tagged, then the @fa<simple_expression> shall resolve to be of a
+type that is convertible (see 4.6) to the tested type; if
+untagged, the expected type for the @fa<simple_expression> is the
+tested type.
+@dby
+The @i<tested type> of a membership test is determined by the @fa<membership_choice>s
+of the @fa<membership_choice_list>. Either all @fa<membership_choice>s of the
+@fa<membership_choice_list> shall resolve to the same type, which is the tested type; or
+each @fa<membership_choice> shall be of an elementary type, and the tested type
+shall be covered by each of these elementary types.>
+
+If the tested type is tagged, then the @fa<simple_expression> shall
+resolve to be of a type that is convertible (see 4.6) to the tested
+type; if untagged, the expected type for the @fa<simple_expression> is
+the tested type. The expected type of a @fa<choice_expression> in a
+@fa<membership_choice>, and of a @fa<simple_expression> of a @fa<range>
+in a @fa<membership_choice>, is the tested type of the membership operation.
+
+!corrigendum 4.5.2(4)
+
+@dinsa
+For a membership test, if the @fa<simple_expression> is of a tagged
+class-wide type, then the tested type shall be (visibly) tagged.
+@dinst
+If a membership test includes one or more choice expressions and
+the tested type of the membership test is limited, then the
+tested type of the membership test shall have a visible
+primitive equality operator.
+
+!corrigendum 4.5.2(27)
+
+@drepl
+For the evaluation of a membership test, the @fa<simple_expression> and
+the @fa<range> (if any) are evaluated in an arbitrary order.
+@dby
+For the evaluation of a membership test whose @fa<membership_choice_list> has a single
+@fa<membership_choice>, the @fa<simple_expression> and the @fa<membership_choice> are
+evaluated in arbitrary order.
+
+For the evaluation of a membership test whose @fa<membership_choice_list> has more than one
+@fa<membership_choice>, the @fa<simple_expression> of the membership test is evaluated first
+and the operation is equivalent to a sequence consisting of an individual test on each
+@fa<membership_choice> combined with the short-circuit control form @b<or else>.
+
+!corrigendum 4.5.2(28)
+
+@drepl
+A membership test using @b<in> yields the result True if:
+@dby
+A membership test using @b<in> yields the result True if any of the individual
+tests on the @fa<membership_choice>s of the @fa<membership_choice_list> yields True.
+
+An individual membership test yields the result True if:
+
+@xbullet<The @fa<membership_choice> is a @fa<choice_expression>, and the @fa<simple_expression>
+is equal to the value of the @fa<membership_choice>. If the tested type is a record type
+or a limited type, the test uses the primitive equality for the type; otherwise the test
+uses predefined equality.>
+
+!corrigendum 4.5.2(29)
+
+@drepl
+@xbullet<The tested type is scalar, and the value of the @fa<simple_expression> belongs to the
+given @fa<range>, or the @fa<range> of the named subtype; or>
+@dby
+@xbullet<The @fa<membership_choice> is a @fa<range> or @fa<subtype_mark>, the tested type is
+scalar, and the value of the @fa<simple_expression> belongs to the given @fa<range>, or the
+@fa<range> of the named subtype.>
+
+!corrigendum 4.5.2(30/2)
+
+@drepl
+The tested type is not scalar, and the value of the @fa<simple_expression> satisfies any
+constraints of the named subtype, and:
+@dby
+@xbullet<The @fa<membership_choice> is a @fa<subtype_mark>, the tested type not is
+scalar, the value of the @fa<simple_expression> satisfies any
+constraints of the named subtype, and>
+
+
+!corrigendum 4.9(11)
+
+@drepl
+@xbullet<a membership test whose @fa<simple_expression> is a static expression,
+and whose @fa<range> is a static range or whose @fa<subtype_mark> denotes a
+static [(scalar or string)] subtype;>
+@dby
+@xbullet<a membership test whose @fa<simple_expression> is a static expression,
+and whose @fa<membership_choice_list> consists only of @fa<membership_choice>s
+each of which is either a static @fa<choice_expression>, a static @fa<range>,
+or a @fa<subtype_mark> that denotes a static [(scalar or
+string)] subtype;>
+
+!corrigendum 4.9(33)
+!comment The following is just to force a conflict; the real wording is in the
+!comment conflict file.
+
+@drepl
+A static expression is evaluated at compile time except when it is part of the
+right operand of a static short-circuit control form whose value is determined
+by its left operand. This evaluation is performed exactly, without performing
+Overflow_Checks. For a static expression that is evaluated:
+@dby
+An expression is @i<statically unevaluated> if it is part of:
!appendix
Questions? Ask the ACAA Technical Agent