CVS difference for ai05s/ai05-0188-1.txt
--- ai05s/ai05-0188-1.txt 2010/10/22 00:59:25 1.11
+++ ai05s/ai05-0188-1.txt 2010/11/25 01:35:28 1.12
@@ -1,13 +1,21 @@
-!standard 3.10.2(9/2) 10-10-21 AI05-0188-1/08
-!standard 3.10.2(19.2/3)
+!standard 3.10.2(9/2) 10-10-30 AI05-0188-1/09
+!standard 3.10.2(32/2)
!standard 4.5.7(0)
-!standard 4.5.8(0)
!standard 4.9(12)
!standard 4.9(33)
+!standard 5.4(2)
+!standard 5.4(4)
+!standard 5.4(6)
+!standard 5.4(7)
+!standard 5.4(8)
+!standard 5.4(9)
+!standard 5.4(11)
+!standard 5.4(12)
!standard 6.2(10)
!standard 6.5(5.5/2)
!class amendment 09-11-03
!status Amendment 2012 10-07-26
+!status ARG Approved 10-0-0 10-10-30
!status work item 09-11-03
!status received 09-11-03
!priority Low
@@ -21,7 +29,7 @@
!problem
Conditional expressions are added by AI05-0147-1. This proposal is to add an
-analogous contruct -- the case expression. We also change the name
+analogous construct -- the case expression. We also change the name
conditional_expression to if_expression, and use conditional_expression to refer
to both if_expression and case_expression.
@@ -94,130 +102,151 @@
The accessibility level of a conditional_expression is the
accessibility level of the evaluated dependent_expression.
-Add after 3.10.2(19.2/3), as a separate bulleted item:
+Add after 3.10.2(32):
- If a given accessibility level is statically deeper than the
- levels of any of the dependent_expressions of a
- conditional_expression, then the given level is statically deeper than
- that of the conditional_expression. Similarly, if the accessibility
- level of any dependent_expression of a conditional_expression is
- statically deeper than some given level, then the accessibility
- level of the conditional_expression is statically deeper than
- the given level.
+ Legality Rules
- AARM note: Roughly speaking, a "statically deeper than"
- relation involving a conditional_expression holds if and
- only if the same relation would hold for some
- dependent_expression of the conditional_expression.
+ An expression is said to have *distributed accessibility*
+ if it is
+ - a conditional_expression (see 4.5.7); or
+ - a view conversion, qualified_expression, or parenthesized
+ expression whose operand has distributed accessibility.
+
+ The statically deeper relationship does not apply to the
+ accessibility level of an expression having distributed accessibility;
+ that is, such an accessibility level is not considered to be
+ statically deeper, nor statically shallower, than any other.
+
+ Any static accessibility requirement that is imposed on an expression
+ that has distributed accessibility (or on its type) is instead imposed on
+ the *dependent_*expressions of the underlying conditional_expression.
+ This rule is applied recursively if a *dependent_*expression also
+ has distributed accessibility.
+
+AARM Discussion:
+This means that any Legality Rule requiring that the accessibility
+level of an expression (or that of the type of an expression)
+shall or shall not be statically deeper than some other level
+instead applies, in the case where the expression has distributed
+accessibility, to each *dependent_*expression of the
+underlying conditional_expression.
+Replace 4.5.7 as added by AI05-0147-1:
-Rename 4.5.7 as added by AI05-0147-1 to If Expressions
-
-Modify the syntax rules in 4.5.7 added by AI05-0147-1:
-
- Change conditional_expression to if_expression.
- Add:
-
- conditional_expression ::= if_expression | case_expression
-
-In 4.5.7, change conditional_expression to if_expression in:
-* The third paragraph of the Legality Rules; and
-* All of the Dynamic Semantics rules.
-
-Replace the introduction of 4.5.7 with:
-
A conditional_expression selects for evaluation at most one of the enclosed
-*dependent_*expressions, depending on some form of condition. One kind of
-conditional_expression is the if_expression, which selects for evaluation
-a *dependent_*expression depending on the value of one or more corresponding
-conditions. Another kind of conditional_expression is defined in 4.5.8.
-
-
-Add a new clause:
+*dependent_*expressions, depending on a decision among the alternatives. One
+kind of conditional_expression is the if_expression, which selects for
+evaluation a *dependent_*expression depending on the value of one or more
+corresponding conditions. Another kind of conditional_expression is the
+case_expression, which selects for evaluation one of a number of alternative
+*dependent_*expressions; the chosen alternative is determined by the value of
+a *selecting_*expression.
-4.5.8 Case expressions
+ Syntax
-One kind of conditional_expression is the case_expression, which selects
-for evaluation one of a number of alternative expressions; the chosen
-alternative is defined by the value of a *selector_*expression.
+conditional_expression ::= if condition then *dependent*_expression
+ {elsif condition then *dependent*_expression}
+ [else *dependent*_expression]
- Syntax
+condition ::= *boolean_*expression
case_expression ::=
- (case *selector_*expression is
+ (case *selecting_*expression is
case_expression_alternative {,
case_expression_alternative}
)
-[Editor's note: "selector_" here is a last minute readability change (especially
-needed for 4.9(12)). I also considered "choosing_" (which just seems weird even
-if consistent with "choices"), "deciding_" (also weird), "case_" (which gives
-the same name as the expression as a whole, too confusing), "determining_", and
-"selecting_". Without this, the wording about choice expressions and this
-expression just gets too confusing. I do worry about confusion with select
-statements, although the word selector is used only once relating to such
-statements.
-
-Probably, a similar change should be made to 5.4 (paragraphs 2, 4, 5, 6, 7,
-8, 9, 11, and 12, AARM 10.b and 10.d). This would avoid confusion with the
-expression in paragraph 5, and make it crystal-clear which rules are referred
-to by the last paragraph of the Name Resolution Rules below.]
-
case_expression_alternative ::=
when discrete_choice_list =>
*dependent*_expression
+Wherever the Syntax Rules allow an expression, a conditional_expression may be
+used in place of the expression, so long as it is immediately surrounded by
+parentheses.
+
+AARM Notes as in AI05-0147-1.
+
Name Resolution Rules
+
+If a conditional_expression is expected to be of a type T, then each
+*dependent_*expression of the conditional_expression is expected to be of type T.
+Similarly, if a conditional_expression is expected to be of some class of types,
+then each *dependent_*expression of the conditional_expression is subject to the
+same expectation. If a conditional_expression shall resolve to be of a type T,
+then each *dependent_*expression shall resolve to be of type T.
+
+The possible types of a conditional_expression are further determined as
+follows:
-Redundant[Name Resolution Rules for the type of the case_expression as a whole
-and the types of the *dependent_*expressions are given in 4.5.7.]
+* If the conditional_expression is the operand of a type conversion, the type of
+ the conditional_expression is the target type of the conversion; otherwise
-AARM Proof: A case_expression is a special case of a conditional_expression, so
-the rules defined for conditional_expressions also apply to case_expressions.
+* If all of the *dependent_*expressions are of the same type, the type of the
+ conditional_expression is that type; otherwise
-The expected type for the *selector_*expression and the discrete_choices are
+* If a *dependent_*expression is of an elementary type, the type of the
+ conditional_expression shall be covered by that type; otherwise
+
+* If the conditional_expression is expected to be of type T or shall resolve to
+ type T, then the conditional expression is of type T.
+
+A condition is expected to be of any boolean type.
+
+The expected type for the *selecting_*expression and the discrete_choices are
as for case statements (see 5.4).
Legality Rules
-
-The expressions and discrete_ranges given as discrete_choices of a
-case_expression shall be static. Redundant[A discrete_choice others, if present,
-shall appear alone and in the last discrete_choice_list.]
-The possible values of the *selector_*expression shall be covered as for case
-statements (see 5.4).
+All of the *dependent_*expressions shall be convertible (see 4.6) to the type of
+the conditional_expression.
-As for case statements, two distinct discrete_choices of a case_expression shall
-not cover the same value.
+If the expected type of a conditional_expression is a specific tagged type, all
+of the *dependent_*expressions of the conditional_expression shall be
+dynamically tagged, or none shall be dynamically tagged; the
+conditional_expression is dynamically tagged if all of the
+*dependent_*expressions are dynamically tagged, is tag-indeterminate if all of
+the *dependent_*expressions are tag-indeterminate, and is statically tagged
+otherwise.
-Redundant[In addition, Legality Rules that apply to all conditional_expressions
-(see 4.5.7) apply to case_expressions.]
+For an if_expression, if there is no "else" *dependent_*expression, all of the
+*dependent_*expressions of the if_expression shall be of a boolean type.
-AARM Proof: A case_expression is a special case of a conditional_expression.
+All Legality Rules that apply to the discrete_choices of a case_statement (see 5.4),
+apply to the discrete_choices of a case_expression.
Dynamic Semantics
-For the execution of a case_expression, the *selector_*expression is
-first evaluated.
-
-If the value of the *selector_*expression is covered by the discrete_choice_list of some
+For the evaluation of an if_expression, the condition specified after
+if, and any conditions specified after elsif, are evaluated in succession
+(treating a final else as elsif True then), until one evaluates to True or
+all conditions are evaluated and yield False. If a condition evaluates to
+True, the associated *dependent_*expression is evaluated, converted to the
+type of the conditional_expression, and the resulting value is the value of the
+if_expression. Otherwise (when there is no else clause), the value
+of the if_expression is True.
+
+AARM Ramification: "Else" is required unless the conditional_expression has
+a boolean type, so the last sentence can only apply to conditional_expressions
+with a boolean type.
+
+For the evaluation of a case_expression, the *selecting_*expression is
+first evaluated. If the value of the *selecting_*expression is covered by the
+discrete_choice_list of some
case_expression_alternative, then the *dependent*_expression of the
case_expression_alternative is evaluated, converted to the type of the
case_expression, and the resulting value is the value of the
-case_expression.
-
-Otherwise (the value is not covered by any discrete_choice_list, perhaps due to
-being outside the base range), Constraint_Error is raised.
+case_expression. Otherwise (the value is not covered by any discrete_choice_list,
+perhaps due to being outside the base range), Constraint_Error is raised.
================
-In 4.9(12.1/3) as added by AI05-0147-1, add "*selector_*expression".
+In 4.9(12.1/3) as added by AI05-0147-1, add "*selecting_*expression".
AI05-0147-1 calls for the replacement of 4.9(33).
Add one more bullet:
* a *dependent_*expression of a case_expression whose
- expression is static and not covered by the
+ *selecting_*expression is static and not covered by the
corresponding discrete_choice_list.
The existing bullet is changed to discuss if_expressions rather than
@@ -245,6 +274,14 @@
expression of the return statement (if any) shall meet the restrictions
described in 7.5.]
+===
+
+Replace the first line of 5.4(2) with:
+ case *selecting_*expression is
+
+In 5.4(4), 5.4(5), 5.4(6), 5.4(7), 5.4(8), 5.4(9), 5.4(11), 5.4(12), and
+AARM 5.4(10.b) and 5.4(10.d), replace "expression" with "*selecting_*expression".
+
!discussion
The changes to 3.10.2, 6.2, and 6.5 are needed to close minor holes in the
@@ -293,116 +330,175 @@
@xbullet<The accessibility level of a @fa<conditional_expression> is the
accessibility level of the evaluated @i<dependent_>@fa<expression>.>
+!corrigendum 3.10.2(32/2)
-!comment Mostly in the conflict file.
-!corrigedum 3.10.2(19/2)
+@dinsa
+@xindent<P'Access yields an access value that designates the subprogram
+denoted by P. The type of P'Access is an access-to-subprogram
+type (@i<S>), as determined by the expected type. The accessibility
+level of P shall not be statically deeper than that of @i<S>. In
+addition to the places where Legality Rules normally apply (see
+12.3), this rule applies also in the private part of an instance
+of a generic unit. The profile of P shall be subtype-conformant
+with the designated profile of @i<S>, and shall not be Intrinsic.
+If the subprogram denoted by P is declared within a generic unit,
+and the expression P'Access occurs within the body of that generic
+unit or within the body of a generic unit declared within
+the declarative region of the generic unit, then the ultimate ancestor
+of @i<S> shall be either a non-formal type declared within the generic
+unit or an anonymous access type of an access parameter.>
+@dinss
+@s8<@i<Legality Rules>>
+An @fa<expression> is said to have @i<distributed accessibility>
+if it is
-@drepl
-@xbullet<The statically deeper relationship does not apply to the accessibility
-level of the anonymous type of an access parameter specifying an
-access-to-object type; that is, such an accessibility level is not
-considered to be statically deeper, nor statically shallower, than
-any other.>
-@dby
-@xbullet<The statically deeper relationship does not apply to the accessibility
-level of the anonymous type of an access parameter specifying an
-access-to-object type nor does it apply to a descendant of a generic
-formal type; that is, such an accessibility level is not
-considered to be statically deeper, nor statically shallower, than
-any other.>
-
-@xbullet<If a given accessibility level is statically deeper than the
-levels of any of the @i<dependent_>@fa<expression>s of a
-@fa<conditional_expression>, then the given level is statically deeper than
-that of the @fa<conditional_expression>. Similarly, if the accessibility
-level of any @i<dependent_>@fa<expression> of a @fa<conditional_expression>
-is statically deeper than some given level, then the accessibility
-level of the @fa<conditional_expression> is statically deeper than
-the given level.>
+@xbullet<a @fa<conditional_expression> (see 4.5.7); or>
+@xbullet<a view conversion, @fa<qualified_expression>, or parenthesized
+expression whose operand has distributed accessibility.>
+
+The statically deeper relationship does not apply to the
+accessibility level of an @fa<expression> having distributed accessibility;
+that is, such an accessibility level is not considered to be
+statically deeper, nor statically shallower, than any other.
+
+Any static
+accessibility requirement that is imposed on an @fa<expression> that
+has distributed accessibility (or on its type) is instead imposed on
+the @i<dependent_>@fa<expression>s of the underlying @fa<conditional_expression>.
+This rule is applied recursively if a @i<dependent_>@fa<expression> also
+has distributed accessibility.
+
!corrigendum 4.5.7
@dinsc
Force a conflict: the real text is in the conflict file.
-!corrigendum 4.5.8
+!corrigendum 4.9(12)
-@dinsc
+@dinsa
+@xbullet<a short-circuit control form both of whose @fa<relation>s are static
+expressions;
+@dinst
+@xbullet<a @fa<conditional_expression> all of whose @fa<condition>s and
+@i<selecting_>@fa<expression>s are static expressions;
-One kind of @fa<conditional_expression> is the @fa<case_expression>, which
-selects for evaluation one of a number of alternative @fa<expression>s; the
-chosen alternative is defined by the value of a @i<selector_>@fa<expression>.
+!corrigendum 4.9(33)
-@s8<@i<Syntax>>
+@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:
-@xcode<@fa<case_expression ::=
- >@ft<@b<case> @i<selector_>>@fa<expression >@ft<@b<is>>@fa<
- case_expression_alternative {,
- case_expression_alternative}>>
+Rest of the wording is found in the conflict file.
-@xcode<@fa<case_expression_alternative ::=
- >@ft<@b<when>>@fa< discrete_choice_list =@>
- >@ft<@i<dependent_>>@fa<expression>>
-@s8<@i<Name Resolution Rules>>
+!corrigendum 5.4(2)
-Name Resolution Rules for the type of the @fa<case_expression> as a whole
-and the types of the @i<selector_>@fa<expression>s are given in 4.5.7.
+@drepl
+@xcode<@fa<case_statement ::=
+ >@ft<@b<case>> @fa<expression >@ft<@b<is>>@fa<
+ case_statement_alternative {,
+ case_statement_alternative}
+ >@ft<@b<end case>>@fa<;>>
+@dby
+@xcode<@fa<case_statement ::=
+ >@ft<@b<case> @i<selecting_>>@fa<expression >@ft<@b<is>>@fa<
+ case_statement_alternative {,
+ case_statement_alternative}
+ >@ft<@b<end case>>@fa<;>>
-The expected type for the @i<selector_>@fa<expression> and the @fa<discrete_choice>s
-are as for case statements (see 5.4).
-@s8<@i<Legality Rules>>
+!corrigendum 5.4(4)
-The @fa<expression>s and @fa<discrete_range>s given as @fa<discrete_choice>s of a
-@fa<case_expression> shall be static. A @fa<discrete_choice> @b<others>,
-if present, shall appear alone and in the last @fa<discrete_choice_list>.
+@drepl
+The @fa<expression> is expected to be of any discrete type.
+The expected type for each @fa<discrete_choice> is the type of the
+@fa<expression>.
+@dby
+The @I<selecting_>@fa<expression> is expected to be of any discrete type.
+The expected type for each @fa<discrete_choice> is the type of the
+@I<selecting_>@fa<expression>.
-The possible values of the @i<selector_>@fa<expression> shall be covered as for
-case statements (see 5.4).
+!corrigendum 5.4(6)
-As for case statements, two distinct @fa<discrete_choice>s of
-a @fa<case_expression> shall not cover the same value.
+@drepl
+The possible values of the @fa<expression> shall be
+covered as follows:
+@dby
+The possible values of the @i<selecting_>@fa<expression> shall be
+covered as follows:
-In addition, Legality Rules that apply to all @fa<conditional_expression>s
-(see 4.5.7) apply to @fa<case_expression>s.
+!corrigendum 5.4(7)
-@s8<@i<Dynamic Semantics>>
+@drepl
+@Xbullet<If the @fa<expression> is a @fa<name> (including a
+@fa<type_conversion> or a @fa<function_call>)
+having a static and constrained nominal subtype, or is a
+@fa<qualified_expression> whose @fa<subtype_mark> denotes a static and
+constrained scalar subtype, then each non-@b<others> @fa<discrete_choice>
+shall cover only values in that subtype, and each value of that
+subtype shall be covered by some @fa<discrete_choice>
+(either explicitly or by @b<others>).>
+@dby
+@Xbullet<If the @i<selecting_>@fa<expression> is a @fa<name> (including a
+@fa<type_conversion> or a @fa<function_call>)
+having a static and constrained nominal subtype, or is a
+@fa<qualified_expression> whose @fa<subtype_mark> denotes a static and
+constrained scalar subtype, then each non-@b<others> @fa<discrete_choice>
+shall cover only values in that subtype, and each value of that
+subtype shall be covered by some @fa<discrete_choice>
+(either explicitly or by @b<others>).>
-For the execution of a @fa<case_expression>, the @i<selector_>@fa<expression> is
-first evaluated.
+!corrigendum 5.4(8)
-If the value of the @i<selector_>@fa<expression> is covered by the
-discrete_choice_list of some @fa<case_expression_alternative>, then the
-@i<dependent_>@fa<expression> of the @fa<case_expression_alternative> is
-evaluated, converted to the type of the @fa<case_expression>, and the resulting
-value is the value of the case_expression.
+@drepl
+@xbullet<If the type of the @fa<expression> is
+@i<root_integer>, @i<universal_integer>, or a descendant of a
+formal scalar type, then the @fa<case_statement> shall have
+an @b<others> @fa<discrete_choice>.>
+@dby
+@xbullet<If the type of the @i<selecting_>@fa<expression> is
+@i<root_integer>, @i<universal_integer>, or a descendant of a
+formal scalar type, then the @fa<case_statement> shall have
+an @b<others> @fa<discrete_choice>.>
-Otherwise (the value is not covered by any @fa<discrete_choice_list>, perhaps
-due to being outside the base range), Constraint_Error is raised.
+!corrigendum 5.4(9)
+@drepl
+@xbullet<Otherwise, each value of the base range of the type of the
+@fa<expression> shall be covered (either explicitly
+or by @b<others>.>
+@dby
+@xbullet<Otherwise, each value of the base range of the type of the
+@i<selecting_>@fa<expression> shall be covered (either explicitly
+or by @b<others>.>
-!corrigendum 4.9(12)
+!corrigendum 5.4(11)
-@dinsa
-@xbullet<a short-circuit control form both of whose @fa<relation>s are static
-expressions;
-@dinst
-@xbullet<a @fa<conditional_expression> all of whose @fa<condition>s and
-@fa<expression>s are static expressions;
+@drepl
+For the execution of a @fa<case_statement> the
+@fa<expression> is first evaluated.
+@dby
+For the execution of a @fa<case_statement> the
+@i<selecting_>@fa<expression> is first evaluated.
-!corrigendum 4.9(33)
+!corrigendum 5.4(12)
@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:
+If the value of the @fa<expression>
+is covered by the @fa<discrete_choice_list> of some
+@fa<case_statement_alternative>, then the
+@fa<sequence_of_statements> of the @fa<_alternative> is executed.
@dby
-An expression is @i<statically unevaluated> if it is part of:
-
-Rest of the wording is found in the conflict file.
+If the value of the @i<selecting_>@fa<expression>
+is covered by the @fa<discrete_choice_list> of some
+@fa<case_statement_alternative>, then the
+@fa<sequence_of_statements> of the @fa<_alternative> is executed.
!corrigendum 6.2(10)
Questions? Ask the ACAA Technical Agent