CVS difference for ai05s/ai05-0148-1.txt

Differences between 1.6 and version 1.7
Log of other versions for file ai05s/ai05-0148-1.txt

--- ai05s/ai05-0148-1.txt	2009/07/11 03:06:22	1.6
+++ ai05s/ai05-0148-1.txt	2009/10/15 04:20:17	1.7
@@ -1,4 +1,4 @@
-!standard 3.10.2(13.1/2)                                09-06-25  AI05-0148-1/05
+!standard 3.10.2(13.1/2)                                09-10-12  AI05-0148-1/06
 !standard 3.10.2(19/2)
 !standard 4.6(24.17/2)
 !standard 4.6(48)
@@ -13,8 +13,11 @@
 
 !summary
 
-(See proposal.)
+The accessibility level of a stand-alone object of an 
+anonymous access type may vary during its lifetime. This increases
+the usefulness of such objects.
 
+
 !problem
 
 The accessibility level of a stand-alone object of
@@ -31,23 +34,23 @@
 the nodes of a linked list, presuming the "Next" component
 of each node is of an anonymous access type:
 
-   type Node is record
+   type Root_Node is tagged record
        ...
-       Next : access Node;
-   end record
+       Next : access Root_Node'Class;
+   end record;
 
 
-   function Reverse(List : access Node) return access Node is
+   function Reverse(List : access Root_Node'Class) return access Root_Node'Class is
      -- Reverse the order of the nodes of the list
-       Result : access Node := null;
-       This_Node : access Node := List;
+       Result : access Root_Node'Class := null;
+       This_Node : access Root_Node'Class := List;
    begin
        -- Iterate through the nodes moving them to the beginning of
        -- the new list.
        while This_Node /= null loop
            -- Put this node on front of new list
          declare
-           Next_Node : constant access Node := This_Node.Next;
+           Next_Node : constant access Root_Node'Class := This_Node.Next;
          begin
            Next_Node := This_Node.Next;
            This_Node.Next := Result;  -- Fails accessibility check
@@ -94,7 +97,7 @@
 Add the following after 3.10.2(13.1/2):
 
    The accessibility level of the type of a stand-alone object of an
-   anonymous access-to-object type is determined by the accessibility
+   anonymous access-to-object type is the same as the accessibility
    level of the type of the access value most recently assigned to the
    object, but is never deeper than that of the declaration of the
    stand-alone object.
@@ -111,7 +114,7 @@
 
    The implementation of accessibility checks for stand-alone objects of
    anonyomous access-to-object types can be similar to that for anonymous
-   access-to-object parameters. A static level sufficies; it can be calculated
+   access-to-object parameters. A static level suffices; it can be calculated
    using rules similar to those previously described for access parameters.
 
    One important difference between the stand-alone access variables and
@@ -127,8 +130,8 @@
    stand-alone object, but the dynamic accessibility of the passed in object
    clearly must be shallower than the stand-alone object (whatever is passed
    in must live at least as long as the subprogram call). We do not need to
-   keep a more local static level as objects statically deeper than the
-   stand-alone object cannot be stored into the stand-alone object.
+   keep a more local static level as accesses to objects statically deeper
+   than the stand-alone object cannot be stored into the stand-alone object.
 
 Change 4.6(24.17/2):
 
@@ -158,16 +161,16 @@
 
 !discussion
 
-The current rule in Ada 2005 makes standalone objects of an
+The current rule in Ada 2005 makes stand-alone objects of an
 anonymous access type useful only to point at local objects,
-which is not of any significant value.  We considered various
-ways of fixing this.  One was to have them take on the
+which is not of any significant value. We considered various
+ways of fixing this. One was to have them take on the
 accessibility level of their initial value, analogous to
 the way the access parameters and access object renames work.
 This certainly seems more useful, but it is not clear what
-to do when an object is initialized to null.  Normally one
+to do when an object is initialized to null. Normally one
 would think of null as being library-level, but perhaps it
-is better thought of being no particular level.
+is better thought of as having no particular level.
 
 An alternative idea was to require that all non-null values
 assigned to a given access object be of the same accessibility
@@ -235,7 +238,7 @@
 accessibility checks at dereferences and a complex scheme of nesting detection.
 (A simple stack check doesn't work, that can be seen in this case where the
 level of the dangling, destroyed object is identical to one that exists,
-but it the object that exists is not the correct one.) The needed check would
+but the object that exists is not the correct one.) The needed check would
 require far too much overhead (and it would be distributed overhead).
 
 
@@ -321,35 +324,33 @@
 
 
 !example
-
-    type Root_Node is tagged record
-        Next : access Root_Node'Class;
-    end record
 
-
-    function Reverse(List : access Root_Node'Class)
-      return access Root_Node'Class is
-      -- Reverse the order of the nodes of the list
-        Result : access Root_Node'Class := null;
-        This_Node : access Root_Node'Class := List;
-    begin
-        -- Iterate through the nodes moving them to the beginning of
-        -- the new list.
-        while This_Node /= null loop
-            -- Put this node on front of new list
-          declare
-            Next_Node : constant access Root_Node'Class := This_Node.Next;
-          begin
-            Next_Node := This_Node.Next;
-            This_Node.Next := Result;  -- Fails accessibility check
-            Result := This_Node;
-
-            -- advance to next node on list
-            This_Node := Next_Node;
-          end;
-        end loop;
-        return Result;  -- Fails accessibility check
-    end Reverse;
+      type Node is tagged record
+          Prev, Next : access Node'Class;
+      end Node;
+ 
+      procedure Swap(A, B : access Node'Class) is
+        -- Swap nodes between circularly-linked lists
+        -- Requires: neither list is part of an empty list
+          pragma Assert(A.Next /= A);
+          pragma Assert(B.Next /= B);
+          After_A : constant access Node'Class := A.Next;
+          Before_A : constant access Node'Class := A.Prev;
+      begin
+          -- Replace A with B
+          Before_A.Next := B;
+          After_A.Prev := B;
+ 
+          A.Next := B.Next;
+          B.Next := After_A;  -- Would fail with old rules
+          A.Prev := B.Prev;
+          B.Prev := Before_A; -- Would fail with old rules
+ 
+          -- Replace B with A
+          A.Next.Prev := A;
+          A.Prev.Next := A;
+      end Swap;
+ 
 
 !corrigendum 3.10.2(13.1/2)
 
@@ -359,7 +360,7 @@
 any master; all such anonymous access types have this same level.>
 @dinst
 @xbullet<The accessibility level of the type of a stand-alone object of an
-anonymous access-to-object type is determined by the accessibility
+anonymous access-to-object type is the same as the accessibility
 level of the type of the access value most recently assigned to the
 object, but is never deeper than that of the declaration of the
 stand-alone object.>
@@ -397,7 +398,7 @@
 normally apply (see 12.3), this rule applies also in the private part
 of an instance of a generic unit.>
 
-!Corrigendum 4.6(48)
+!corrigendum 4.6(48)
 
 @drepl
 @xinbull<For an access-to-object type, a check is made that the accessibility

Questions? Ask the ACAA Technical Agent