CVS difference for ai05s/ai05-0188-1.txt
--- ai05s/ai05-0188-1.txt 2010/02/16 23:58:25 1.5
+++ ai05s/ai05-0188-1.txt 2010/02/25 03:30:43 1.6
@@ -1,4 +1,4 @@
-!standard 4.3.3(14) 10-02-03 AI05-0188-1/03
+!standard 4.3.3(14) 10-02-24 AI05-0188-1/04
!standard 4.4(1)
!standard 4.5.8(0)
!standard 4.9(12)
@@ -17,17 +17,18 @@
!problem
-Conditional_expressions are added by AI05-0147-1. This proposal is to add an
-analogous contruct -- the case expression.
+Conditional expressions are added by AI05-0147-1. This proposal is to add an
+analogous contruct -- 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.
The full coverage rules for case statements and aggregates are a huge benefit to
maintenance of Ada programs: If you add an enumeration literal, the compiler
tells you about all the case statements and aggregates that need to be modified
(assuming you don't defeat the full coverage rules by using "others").
-In cases where conditional_expressions are useful, we don't want to lose the
-benefits of full coverage rules. A common example is in preconditions. Suppose
-we have:
+In cases where if_expressions are useful, we don't want to lose the benefits of
+full coverage rules. A common example is in preconditions. Suppose we have:
procedure Add_To_Fruit_Salad( -- In a package spec.
Fruit : in out Fruit_Type; Bowl : in out Bowl_Type);
@@ -85,21 +86,17 @@
!wording
-Add a bullet following 4.3.3(14):
+Rename 4.5.7 as added by AI05-0147-1 to If Expressions
-* For a conditional_expression or case_expression, the applicable index
- constraint for each *dependent_*expression is that, if any, defined for the
- conditional or case_expression;
+Modify the syntax rules in 4.5.7 added by AI05-0147-1:
-(Minor detail: AI05-0147-1 suggests this should go after (15), but it seems
-better after (14).)
+ Change conditional_expression to if_expression.
+ Add:
-Modify 4.4(1) to add conditional and case expressions, as follows:
+ conditional_expression ::= if_expression | case_expression
- In this International Standard, the term "expression" refers to a construct
- of the syntactic category expression or of any of the following
- categories: relation, simple_expression, term, factor, primary,
- conditional_expression, case_expression.
+In the Legality Rules, Static Semantics, and Dynamic Semantics rules of 4.5.7
+change conditional_expression to if_expression.
Add a new clause:
@@ -120,12 +117,6 @@
when discrete_choice_list =>
*dependent*_expression
-Wherever the Syntax Rules allow an expression, a case_expression may be used in
-place of the expression, so long as it is immediately surrounded by parentheses.
-
-[AARM: Note that the above is the same rule as for conditional_expressions; see
-4.5.7 for further discussion.]
-
Name Resolution Rules
The expected type for the expression and the discrete_choices are as for case
@@ -135,6 +126,11 @@
*dependent_*expression of the case_expression is T. If a case_expression shall
resolve to a type T, each dependent_expression shall resolve to T.
+AARM To Be Honest: T in this rule could be any type in a class of types
+ (including the class of all types), or (for the second rule) an anonymous
+ access type (for renames) or a universal type covering some type (for
+ qualified expressions).
+
Legality Rules
The expressions and discrete_ranges given as discrete_choices of a
@@ -175,29 +171,24 @@
================
-Add after 4.9(12):
-
-* A case_expression all of whose expressions are static expressions;
-
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
corresponding discrete_choice_list.
-
-Modify 7.5(2.1/2):
-In the following contexts, an expression of a limited type is not permitted
-unless it is an aggregate, a function_call, [or ]a parenthesized expression or
-qualified_expression whose operand is permitted by this rule{, or a conditional_
-or case_expression all of whose *dependent_*expressions are permitted by this
-rule}:
+The existing bullet is changes to discuss if_expressions rather than
+conditional_expression.
!discussion
+(See !problem.)
+
!examples
+(See !problem.)
+
!ACATS test
ACATS B and C tests are needed.
@@ -668,5 +659,107 @@
* A case_expression all of whose expressions are static expressions;
seems to be good enough.
+
+****************************************************************
+
+From: Bob Duff
+Sent: Wednesday, February 24, 2010 2:41 PM
+
+New version of AI05-0188-1, "Case expressions".
+
+I'm not sure this is entirely correct, since it's supposed to depend on
+AI05-0147-1, which Tucker has not yet updated.
+
+I am assuming that AI05-0147-1 covers these issues, with wording that still
+works for this AI (AI05-0188-1).
+
+ - applicable index constraint
+
+ - Wording similar to this:
+
+ Modify 4.4(1) to add conditional_expressions, as follows:
+
+ In this International Standard, the term "expression" refers to a
+ construct of the syntactic category expression or of any of the
+ following categories: relation, simple_expression, term, factor,
+ primary, conditional_expression.
+
+ - Wherever the Syntax Rules allow an expression, a case_expression may be
+ used in place of the expression, so long as it is immediately surrounded
+ by parentheses.
+
+ [AARM: Note that the above is the same rule as for conditional_expressions;
+ see 4.5.7 for further discussion.]
+
+ - Static expressions (4.9(12, 33)):
+
+ - 7.5(2.1/2) -- "In the following contexts, an expression of a limited type
+ is not permitted unless...."
+
+[Following was version /04 of this AI - Editor.]
+
+****************************************************************
+
+From: Steve Baird
+Sent: Wednesday, February 24, 2010 5:00 PM
+
+> If a case_expression is expected to be of a type T, the expected type
+> for each *dependent_*expression of the case_expression is T. If a
+> case_expression shall resolve to a type T, each dependent_expression shall resolve to T.
+>
+
+The corresponding wording for if_expressions (formerly
+conditional_expressions) has a TBH note because it was decided that saying what
+we really mean here is too much trouble. (Just to recap, I'm referring to the
+interaction between this wording and, e.g., the rule for qualified expressions
+(4.7(3)) or for conditions (5.3(4))).
+
+Don't we need to do that again here?
+
+****************************************************************
+
+From: Bob Duff
+Sent: Wednesday, February 24, 2010 5:50 PM
+
+Yeah, or better yet, make sure the if_expr AI is worded in a way that obviates
+the need for duplicating the wording for case_exprs. That's Tuck's job.
+
+I was told to make the case_expr AI depend on the if_expr AI, but not the other
+way 'round. But the if_expr AI needs to "secretly" depend on the case_expr AI,
+in the sense that the wording has to be carefully crafted to cover case_exprs.
+
+****************************************************************
+
+From: Randy Brukardt
+Sent: Wednesday, February 24, 2010 6:02 PM
+
+...
+>Yeah, or better yet, make sure the if_expr AI is worded in a way that
+>obviates the need for duplicating the wording for case_exprs. That's
+Tuck's job.
+
+Bob, there is no open homework on AI05-0147-1. It's (supposedly) finished as I
+posted it (sometime after Feb 4). I believe I extracted the needed wording from
+Tuck right after the last meeting.
+
+So if there is something that needs to be changed about it, please tell us.
+
+****************************************************************
+
+From: Randy Brukardt
+Sent: Wednesday, February 24, 2010 9:27 PM
+
+> - Static expressions (4.9(12, 33)):
+
+4.9(33) is about unselected branches in if_expressions. That depends on the
+definition of "condition" and the execution of if statements. That wording
+cannot be made to work for case expressions, because the terminology for the two
+kinds of statements is completely different (you have to use something about
+"covers"). I left that wording in the draft!
+
+We need some wording in here to say that 4.5.7 as added by AI-147-1 is renamed
+to If expressions, and all uses of conditional_expression in Legality Rules,
+Static Semantics, and Dynamic Semantics are changed to if_expression. I added
+that.
****************************************************************
Questions? Ask the ACAA Technical Agent