CVS difference for ai12s/ai12-0047-1.txt
--- ai12s/ai12-0047-1.txt 2013/01/01 03:10:23 1.2
+++ ai12s/ai12-0047-1.txt 2013/01/01 04:27:31 1.3
@@ -1,6 +1,8 @@
-!standard 4.6(8/2) 12-12-08 AI12-0047-1/02
-!standard 4.6(24.8/2)
+!standard 5.5.2(6/3) 12-12-31 AI12-0047-1/03
+!standard 7.6.1(3/2)
!class binding interpretation 12-12-01
+!status Amendment 202x 12-12-31
+!status ARG Approved 11-0-0 12-12-08
!status work item 12-12-01
!status received 12-11-12
!priority Medium
@@ -8,8 +10,12 @@
!subject Generalized iterators and finalization of the associated object
!summary
-** TBD.
+The iterable_name or iterator_name of a iterator cannot be a discriminant-dependent
+subcomponent of a mutable type.
+The iterable_name or iterator_name of a iterator is not finalized until the loop
+completes.
+
!question
1) Consider:
@@ -20,7 +26,7 @@
record F : String (1 .. Last); end record;
X : Rec;
- begin
+ begin
for Char of X.F loop
X := (0, "");
Char := '?';
@@ -37,7 +43,7 @@
Consider:
- For I of Func_Returning_Array_With_Controlled_Elements loop
+ for I of Func_Returning_Array_With_Controlled_Elements loop
The rule above means that the function call result object gets
finalized before beginning the first iteration of the loop.
@@ -54,8 +60,8 @@
Add after 5.5.2(6/3):
-The iterator_name or iterable_name of a iterator_specification shall
-not be a subcomponent that depends on discriminants of an object
+The iterator_name or iterable_name of an iterator_specification shall
+not denote a subcomponent that depends on discriminants of an object
whose nominal subtype is unconstrained, unless the object is known
to be constrained.
@@ -76,7 +82,7 @@
The above definition states that only scalar, as opposed to all,
expressions and function calls occurring immediately within a compound
-statement are masters. This distinction only makes a difference in the
+statement are masters. This distinction only matters in the
case of a loop statement with an iterator_specification because other
compound statements (e.g., case statements) can only immediately
enclose scalar expressions. When iterating over the result of a
@@ -85,22 +91,11 @@
first iteration of the loop. This rule accomplishes that.
!discussion
-
-The easiest way to fix problem #1 is to follow the lead of renaming. Either
-define this to directly be a renaming (and then enforce the Legality Rules
-appropriately), or just add the important rule into 5.5.2:
-
-The iterator_name or iterable_name of a iterator_specification shall not be a
-subcomponent that depends on discriminants of an object a variable whose nominal
-subtype is unconstrained, unless the object is known to be constrained.
-
-The solution to problem #2 should not cause the finalization of Function_Call
-in
- for I in 1 .. Function_Call.Scalar_Field loop
-to be deferred to the end of the loop.
-A suggestion has been made to define the object to be a renaming of the
-iterator_name or iterable_name. However, that implies that the object can be
+Problem #1 is solved by following the lead of renaming. We directly repeat
+the interesting rule as defining iterators in terms of renaming would
+drag in other rules that may or may not be appropriate. In particular, it
+would require that the object can be
clobbered inside the loop (with unpredictable results for a container iterator):
for E of X loop
@@ -110,7 +105,55 @@
end loop;
Ada.Containers has tampering checks to prevent this situation (the assignment
-would raise Program_Error), but user-defined packages may not.
+would raise Program_Error), but user-defined packages may not. So we do not
+take this approach.
+
+Problem #2 is solved by defining function_calls are not masters if they are
+composite. This is not expected to make any change to any construct other than
+loops, as other kinds of component statement (like case statements and if
+statements) can only "consume" a scalar expression.
+
+It's important that the treatment of scalar calls not change. We don't want the
+finalization of Function_Call in
+ for I in 1 .. Function_Call.Scalar_Field loop
+to be deferred to the end of the loop.
+
+!corrigendum 5.5.2(6/3)
+
+@dinsa
+In a container element iterator whose @i<iterable_>@fa<name> has
+type @i<T>, if the @i<iterable_>@fa<name> denotes a
+constant or the Variable_Indexing aspect is not specified for @i<T>,
+then the Constant_Indexing aspect shall be specified for @i<T>.
+@dinst
+The @i<iterator_>@fa<name> or @i<iterable_>@fa<name> of an
+@fa<iterator_specification> shall not denote a subcomponent that
+depends on discriminants of an object whose nominal subtype is
+unconstrained, unless the object is known to be constrained.
+
+!corrigendum 7.6.1(3/2)
+
+@drepl
+After execution of a construct or entity is complete, it is @i<left>, meaning
+that execution continues with the next action, as defined for the execution
+that is taking place. Leaving an execution happens immediately after its
+completion, except in the case of a @i<master>: the execution of a body other than
+a @fa<package_body>; the execution of a @fa<statement>; or
+the evaluation of an @fa<expression>, @fa<function_call>, or @fa<range>
+that is not part of an enclosing @fa<expression>, @fa<function_call>, @fa<range>, or
+@fa<simple_statement> other than a @fa<simple_return_statement>.
+A master is finalized after it is complete, and before it is left.
+@dby
+After execution of a construct or entity is complete, it is @i<left>, meaning
+that execution continues with the next action, as defined for the execution
+that is taking place. Leaving an execution happens immediately after its
+completion, except in the case of a @i<master>: the execution of a body other than
+a @fa<package_body>; the execution of a @fa<statement>; or
+the evaluation of a scalar @fa<expression>, a scalar @fa<function_call>, or a @fa<range>
+that is not part of an enclosing @fa<expression>, @fa<function_call>, @fa<range>, or
+@fa<simple_statement> other than a @fa<simple_return_statement>.
+A master is finalized after it is complete, and before it is left.
+
!ACATS test
Questions? Ask the ACAA Technical Agent