CVS difference for ai05s/ai05-0153-3.txt

Differences between 1.15 and version 1.16
Log of other versions for file ai05s/ai05-0153-3.txt

--- ai05s/ai05-0153-3.txt	2011/04/11 23:47:29	1.15
+++ ai05s/ai05-0153-3.txt	2011/04/20 20:18:48	1.16
@@ -1,4 +1,4 @@
-!standard  3.2.4(0)                                11-04-07    AI05-0153-3/08
+!standard  3.2.4(0)                                11-04-20    AI05-0153-3/09
 !class Amendment 09-05-27
 !status Amendment 2012 11-03-04
 !status ARG Approved  7-0-1  11-02-18
@@ -54,8 +54,8 @@
 
     type T is ...;
     function Is_Good(X: T) return Boolean;
-    subtype Good_T is T with
-        Dynamic_Predicate => Is_Good(Good_T);
+    subtype Good_T is T
+       with Dynamic_Predicate => Is_Good(Good_T);
 
 Good_T conceptually represents the subset of values of type T for
 which Is_Good returns True.
@@ -88,8 +88,8 @@
 Certain subtypes with Static_Predicates are defined to be static.
 For example,
 
-    subtype Letter is Character with
-        Static_Predicate => Letter in 'A'..'Z' | 'a'..'z';
+    subtype Letter is Character
+       with Static_Predicate => Letter in 'A'..'Z' | 'a'..'z';
 
 Letter is a static subtype.  (Actually, it should probably include
 things like '' -- this is just an example!)
@@ -439,8 +439,8 @@
 but it was previously impossible to give a subtype name for
 'A'..'Z' | 'a'..'z'.  We now allow:
 
-    subtype Letter is Character with
-        Static_Predicate => Letter in 'A'..'Z' | 'a'..'z';
+    subtype Letter is Character
+       with Static_Predicate => Letter in 'A'..'Z' | 'a'..'z';
 
     case Current_Char is
         when Letter => ... -- Allowed by this AI.
@@ -459,8 +459,8 @@
 whose size is roughly proportional to the size of the relevant source text.  For
 example:
 
-    subtype Even is Natural with
-        Static_Predicate => Cur_Inst mod 2 = 0; -- Illegal!
+    subtype Even is Natural
+       with Static_Predicate => Cur_Inst mod 2 = 0; -- Illegal!
 
 doesn't qualify, because the the subrange sequence would be
 something like 0..0, 2..2, 4..4, ... 2**31-2..2**31-2, which is
@@ -473,10 +473,10 @@
 Note that the definition of static subtypes allows predicates
 coming from other subtypes:
 
-    subtype S1 is Natural with
-        Static_Predicate => S1 < 100 or S1 > 1000;
-    subtype S2 is S1 with
-        Static_Predicate => S2 <= 50_000;
+    subtype S1 is Natural
+       with Static_Predicate => S1 < 100 or S1 > 1000;
+    subtype S2 is S1
+       with Static_Predicate => S2 <= 50_000;
 
 S1 is a static subtype, with the subrange sequence 0..99, 1001..Natural'Last.
 S2 is also static, with the subrange sequence 0..99, 1001..50_000.
@@ -495,14 +495,15 @@
 
     type Animal is (Dog, Cat, Shark, Boa_Constrictor);
 
-    subtype Pet is Animal with Static_Predicate => Pet in Dog | Cat;
+    subtype Pet is Animal
+       with Static_Predicate => Pet in Dog | Cat;
 
 But now if Parrot is added to Animal, there is no warning that the programmer
 had better decide whether it makes a good pet.  It might be better to use
 a case_expression, in order to benefit from the full coverage rule:
 
-    subtype Pet is Animal with
-        Static_Predicate =>
+    subtype Pet is Animal
+       with Static_Predicate =>
             (case Pet is
                 when Dog | Cat => True,
                 when Shark | Boa_Constrictor => False);
@@ -770,8 +771,8 @@
 some arbitrary junk (possibly invalid) value.
 
     type T is access all String;
-    subtype S is T with
-        Dynamic_Predicate => S.all'First = 1;
+    subtype S is T
+       with Dynamic_Predicate => S.all'First = 1;
     X: S; -- predicate is not checked
     Y: S := null; -- raises an exception
 
@@ -792,8 +793,8 @@
         record
             Inner: Inner_Record;
         end record;
-    subtype S is Outer_Record with
-        Dynamic_Predicate => ...;
+    subtype S is Outer_Record
+       with Dynamic_Predicate => ...;
     X: S; -- predicate IS checked
 
 But if we remove the explicit defaults for A and B,
@@ -833,20 +834,20 @@
 
 Note that overlapping subsets are allowed in the static case:
 
-    subtype S1 is Integer with
-        Static_Predicate => S1 in 1..10;
-    subtype S2 is Integer with
-        Static_Predicate => S2 in 4..20;
-    subtype S3 is Integer with
-        Static_Predicate => S3 in S1 | S2; -- overlapping; same as 1..20
+    subtype S1 is Integer
+       with Static_Predicate => S1 in 1..10;
+    subtype S2 is Integer
+       with Static_Predicate => S2 in 4..20;
+    subtype S3 is Integer
+       with Static_Predicate => S3 in S1 | S2; -- overlapping; same as 1..20
 
     case ... is
-        when S3 => -- OK
+       when S3 => -- OK
 
 But:
 
     case ... is
-        when S1 | S2 => -- Still illegal!
+       when S1 | S2 => -- Still illegal!
 
 ----------------
 
@@ -876,10 +877,10 @@
 
     type Symbol_Ptr is access all Symbol_Record;
 
-    subtype Type_Symbol_Ptr is not null Symbol_Ptr with
-       Dynamic_Predicate => Type_Symbol_Ptr.Entity = A_Type;
-    subtype Callable_Symbol_Ptr is not null Symbol_Ptr with
-       Dynamic_Predicate =>
+    subtype Type_Symbol_Ptr is not null Symbol_Ptr
+       with Dynamic_Predicate => Type_Symbol_Ptr.Entity = A_Type;
+    subtype Callable_Symbol_Ptr is not null Symbol_Ptr
+       with Dynamic_Predicate =>
           Callable_Symbol_Ptr.Entity = Proc or
           Callable_Symbol_Ptr.Entity = Func or
           Callable_Symbol_Ptr.Entity = An_Entry;
@@ -2809,10 +2810,67 @@
 the extended membership test, and set constraints are handled by static
 predicates. So the only thing you can't do natively is dynamically construct a
 set to use in those contexts -- and that can be handled adequately by a set
-package (and dynamic predicates), since it that isn't commonly used.
+package (and dynamic predicates), since it isn't commonly used.
 
 So I don't see why we'd want to spend a lot of effort on "proper sets", whatever
 that is. It's probably about 400th on the priority list for Ada 2020...
+
+****************************************************************
+
+From: Robert Dewar
+Sent: Saturday, April 9, 2011  4:22 AM
+
+> ...
+>> And I think that static predicates are THE most interesting and
+>> useful feature of Ada 2012, ...
+>
+> I wouldn't go quite that far (preconditions would have to be high on
+> the list), but since they provide the set constraints that Ada never
+> had and always has needed, I do agree that they are very useful.
+
+Ah, true, but for me preconditions and postconditions have been around for a
+while pre-Ada2012 :-)
+
+****************************************************************
+
+From: John Barnes
+Sent: Monday, April 11, 2011  5:23 AM
+
+> And I think that static predicates are THE most interesting and useful
+> feature of Ada 2012, I am quite sure that GNAT will implement them
+> even if they are removed from Ada 2012 (seeing as
+...
+
+It's not that I dislike the idea of Static predicates. Its just that I dislike
+the sort-of-static rules that prevent Even from being allowed just because it
+has mod in it.
+
+That has really upset me. I know, I get upset easily.
+
+****************************************************************
+
+From: Robert Dewar
+Sent: Monday, April 11, 2011  1:08 PM
+
+But do you want to throw the baby out with the bathwater here.
+The staticness rules and the effect of non-contiguous enumeration subtypes (the
+main use of static predicates) are really not impacted by the mod issue (and
+*surely* you see the implementation issues in trying to include mod???)
+
+****************************************************************
+
+From: Bob Duff
+Sent: Monday, April 11, 2011  2:11 PM
+
+Even is still allowed.  You can say:
+
+    subtype Even is Integer with
+        Dynamic_Predicate => Even mod 2 = 0;
+
+You cannot say "when Even =>" in a case statement, but that was true before the
+split from Predicate to Static_Predicate/Dynamic_Predicate.
+
+Does this make you happier?
 
 ****************************************************************
 

Questions? Ask the ACAA Technical Agent