CVS difference for ai22s/ai22-0005-1.txt

Differences between 1.10 and version 1.11
Log of other versions for file ai22s/ai22-0005-1.txt

--- ai22s/ai22-0005-1.txt	2023/12/08 10:01:04	1.10
+++ ai22s/ai22-0005-1.txt	2023/12/14 06:07:30	1.11
@@ -472,6 +472,122 @@
 
 [Handled]
 
+****************************************************************
+
+From: Github issue #72, Tucker Taft
+Sent: December 1, 2023
+
+Exactly when should a dynamic subtype on an array subtype be invoked? In
+particular, if the first subtype of an array type has a predicate such as:
+
+  type A1 is array (Positive range <>) of Integer
+     with Dynamic_Predicate => A'First = 1;
+
+is it inevitable that you will get a predicate failure if you write a slice
+of an array object of such a type with a low bound other than one? For example,
+should the following succeed or fail:
+
+  X5 : A1 (1 .. 5);
+  X2 : A1 (1 .. 2) := X5 (3 .. 4);
+
+I hope it would succeed. I would suggest that a slice is an object of a new 
+subtype of the type, without any predicate, and in any case, any predicate on 
+the first subtype of the array type doesn't apply. Otherwise, it could be very
+hard to use such an array type.
+
+Similarly, an aggregate of such a type could have something other than a low 
+bound of 1:
+
+X3 : A1 (1 .. 3) := (2 => 2, 3 => 3, 4 => 4);
+
+I believe this should also succeed.
+
+The Ada RM defines subtype predicate checks as being associated with subtype 
+conversion (RM 3.2.4(31/5)), but there is no subtype conversion associated with
+an aggregate or a slice as far as I can see, unless you explicitly write a
+qualified expression. Note also that when the first subtype of an array type
+is constrained, you can nevertheless do slicing and concatenation of objects
+that do not satisfy the first subtype's constraint, since these operations
+operate on the underlying type, rather than the first subtype.
+
+[Editor's note: I've only included the most relevant parts of this Github issue
+here.]
+
+****************************************************************
+
+From: Github issue #72, Steve Baird
+Sent: December 5, 2023
+
+FWIW, I agree with Tuck's reasoning and conclusions. With many language issues,
+there are separate questions about what the RM says and what it should say.
+Let's start with the latter. It has been well established since Ada83 that the
+constraint (if any) of the first subtype of an array type is not checked for a
+slice, an aggregate, or an actual parameter in a call to a predefined operator
+such as "=" or "&". Given that constraint checking works that way (which
+nobody is disputing), it would be very irregular if predicate checking worked
+differently. And Tuck points out what the the RM does say (if only by omission)
+is consistent with this interpretation. So a note clarifying this point would
+probably be a good thing, but it would only be a clarification (as opposed to
+a change to the language definition).
+
+****************************************************************
+
+From: Github issue #72, Randy Brukardt
+Sent: December 6, 2023
+
+The design of predicates was very intentional to be as close to "user-defined 
+constraints" as possible. The "omission" as Steve calls it was an intentional
+design decision, to make it easier on both users and implementers (the latter
+because they don't need to look for new places to make checks).
+
+So I don't understand the point of this question. The RM clearly specifies 
+where checks are made (and certainly they're not made elsewhere), those places
+match one's intuition about what one would want, so nothing seems wrong OR
+unclear.
+
+I was confused by Tucker's examples:
+
+    X3 : A1 (1 .. 3) := (2 => 2, 3 => 3, 4 => 4);
+
+    The Ada RM defines subtype predicate checks as being associated with
+    subtype conversion (RM 3.2.4(31/5)), but there is no subtype conversion
+    associated with an aggregate or a slice as far as I can see ...
+
+There is of course a subtype conversion associated with the assignment, and
+for most purposes that is indistiguishable from one of the slice or aggregate.
+But I see that's not true for assignments into array objects, as the sliding
+happens first. Again that is very clear in 4.6.
+
+So, I don't see the need for even a ramification AI on this one. We don't 
+write notes that something not mentioned doesn't happen, in part because there
+is an infinite number of such things.
+
+Agreed? Can this topic be marked as adequately answered and closed??
+
+****************************************************************
+
+From: Github issue #72, Tucker Taft
+Sent: December 7, 2023
+
+I guess I would like to see an AARM note. For example, we could augment
+AARM 3.6(16.a/3) as follows:
+
+Discussion: Although there is no nameable unconstrained array subtype in this
+case, the predefined slicing and concatenation operations can operate on and
+yield values that do not necessarily belong to the first array subtype. This
+is also true for Ada 83. {Similarly, if a Dynamic_Predicate applies to the
+first subtype of an array type, it is not checked on a slice or an aggregate
+of the type, until it is converted to a subtype to which the predicate
+applies.}
+
+****************************************************************
+
+From: Github issue #72, Randy Brukardt
+Sent: December 10, 2023
+
+OK, I've added this note change to AI22-0005-1. [This AI, editor.]
+
+[Handled.]
 
 ****************************************************************
 

Questions? Ask the ACAA Technical Agent