CVS difference for ais/ai-00340.txt

Differences between 1.4 and version 1.5
Log of other versions for file ais/ai-00340.txt

--- ais/ai-00340.txt	2004/01/23 04:59:28	1.4
+++ ais/ai-00340.txt	2004/05/29 00:38:39	1.5
@@ -26,6 +26,8 @@
 
 !wording
 
+In 3.5.4(16) change the words "attribute is" to "attributes are".
+
 Add after 3.5.4(16):
 
 S'Mod           S'Mod denotes a function with the following specification:
@@ -34,9 +36,6 @@
                 This function returns Arg mod S'Modulus, as a value of the
                 type of S.
 
-The words "attribute is" would have to be changed to "attributes are"
-in 3.5.4(16).
-
 !example
 
     type Integer_32 is range -(2**31) .. 2**31 - 1;
@@ -44,14 +43,14 @@
 
     Offset    : Integer_32;
     Curr_Addr : Address;
-    . . .
+    ...
     Curr_Addr := Curr_Addr + Address'Mod (Offset);
 
 !discussion
 
 It can be difficult or impossible to mix signed and unsigned expressions, yet
 this is a common programming problem. To see just how painful this can be,
-let's consider a particular example:
+let's consider a particular example.
 
 Suppose we are writing a processor simulator framework. In order to make it
 as general as possible, we make the framework a generic which takes the
@@ -121,7 +120,7 @@
             return Base_Address - Address_Type(-Offset);
         end if;
 
-But this is illegal, because the type of the first test don't match. Moreover,
+But this is illegal, because the types of the first test don't match. Moreover,
 
         if Offset_Type'Base(Address_Type'Modulus) <= Offset_Type'Last then
 
@@ -149,25 +148,27 @@
 Even this can fail if the implementation doesn't follow Implementation Advice
 3.5.4(29) and allows an integer bigger than System.Max_Binary_Modulus. To make
 this work in that case would require handling Constraint_Error if it is
-raised by the test. (The exact code needed will be left as an exercise for the
+raised by the test. (The exact code needed is left as an exercise for the
 reader.)
 
 
-The new attribute allows this to be written as:
+The new Mod attribute solves all of these difficulties since the return
+statement can simply be written as:
 
         return Base_Address + Address_Type'Mod(Offset);
 
 which is many times easier and much more likely to be correct.
 
 
-The Mod attribute can be implemented by just this code (with Base_Address
-replaced by 0). It will never overflow. But a compiler, unlike an Ada
-programmer, can evaluate the first test properly without introducing additional
-types. Moreover, in most circumstances, that test can be evaluated at
-compile-time, and the code can be simplified. Indeed, if Address_Type'Modulus =
-2**Offset_Type'Base'Size, no code at all is needed to implement 'Mod. It seems
-unlikely that a compiler would be smart enough to reduce the entire block of
-code needed in the generic as outlined above to the machine code for:
+The Mod attribute can be implemented by the code block given previously (with
+Base_Address replaced by 0). It will never overflow. But a compiler, unlike an
+Ada programmer, can evaluate the first test properly without introducing
+additional types. Moreover, in most circumstances, that test can be evaluated
+at compile-time, and the code can be simplified. Indeed, if
+Address_Type'Modulus = 2**Offset_Type'Base'Size, no code at all is needed to
+implement 'Mod. It seems unlikely that a compiler would be smart enough to
+reduce the entire block of code needed in the generic as outlined above to the
+machine code for:
 
         return Base_Address + Offset;
 

Questions? Ask the ACAA Technical Agent