CVS difference for ai12s/ai12-0037-1.txt

Differences between 1.2 and version 1.3
Log of other versions for file ai12s/ai12-0037-1.txt

--- ai12s/ai12-0037-1.txt	2012/12/05 04:18:26	1.2
+++ ai12s/ai12-0037-1.txt	2012/12/29 05:23:39	1.3
@@ -1,5 +1,7 @@
-!standard A.19(4/3)                                   12-11-29    AI12-0037-1/01
+!standard A.19(4/3)                                   12-12-28    AI12-0037-1/02
 !class binding interpretation 12-11-29
+!status Amendment 202x 12-12-28
+!status ARG Approved 7-0-3  12-12-07
 !status work item 12-11-29
 !status received 12-08-06
 !priority Low
@@ -29,29 +31,49 @@
 Replace A.19(4/3) with:
 
    type Language_Code is new String(1 .. 3)
-      with Dynamic_Predicate => (for all E of Language_Code =>
-         (if E not in 'a' .. 'z' then raise Constraint_Error);
+      with Dynamic_Predicate => (for all E of Language_Code => E in 'a' .. 'z');
    type Country_Code is new String(1 .. 2)
-      with Dynamic_Predicate => (for all E of Country_Code =>
-         (if E not in 'a' .. 'z' then raise Constraint_Error);
+      with Dynamic_Predicate => (for all E of Country_Code  => E in 'A' .. 'Z');
 
-[Did I manage use the maximum new features here? :-) - RLB]
+Add an AARM note following:
 
+These types are declared as derived from type String so that they can easily be
+converted to or from type String. That's important if one of these values needs to be
+input or displayed (via Text_IO, perhaps). We use the predicate to ensure that only
+possible component values are used. Ada does not allow converting between
+unrelated types with components that don't statically match, so We cannot declare
+new types with constrained components if we want conversions to or from type String.
+
 !discussion
 
-This change is compatible with the original Ada 2012 definition; the only difference
-is that conversions to and from type String are now allowed.
+The use of a predicate rather than constrained component subtypes means that this
+change is inconsistent with the original Ada 2012 definition - the exception raised
+on failure is changed. We don't consider that important as it is unlikely that users
+will construct these values and when they do, it is highly unlikely that they would
+handle any resulting exception (which would represent a bug).
+
+We could have used a raise_expression as described in AI12-0022-1 to avoid this
+inconsistency, but the exception raised wasn't considered important enough to use
+the extra machinery. (We also avoid the problem addressed by AI12-0054-1 by using
+this formulation; any technique for raising Constraint_Error would suffer from
+that problem.)
 
 The predicate could have been written in a number of other ways; this one doesn't
 depend explicitly on the bounds of the subtypes, so it is preferred. Of course, an
 implementation can replace this by anything equivalent if that will provide better
 performance.
+
+!corrigendum A.19(4/3)
+
+@drepl
+@xcode<   @b<type> Language_Code @b<is array> (1 .. 3) @b<of> Character @b<range> 'a' .. 'z';
+   @b<type> Country_Code @b<is array> (1 .. 2) @b<of> Character @b<range> 'A' .. 'Z';>
+@dby
+@xcode<   @b<type> Language_Code @b<is new> String(1 .. 3)
+      @b<with> Dynamic_Predicate => (@b<for all> E @b<of> Language_Code => E @b<in> 'a' .. 'z');
+   @b<type> Country_Code @b<is new> String(1 .. 3)
+      @b<with> Dynamic_Predicate => (@b<for all> E @b<of> Country_Code  => E @b<in> 'A' .. 'Z');>
 
-Note that this predicate uses a raise expression as described in AI12-0022-1. We
-could avoid this by defining a function Raise_Constraint_Error (which would do what
-its name implies), but that would involve some name pollution when use clauses
-are used. [The AI12-0022-1 capability is so important that we ought to consider
-reclassifying it a "binding interpretation" so we can use it here - Editor.]
 
 !ACATS test
 

Questions? Ask the ACAA Technical Agent