CVS difference for ais/ai-00326.txt

Differences between 1.1 and version 1.2
Log of other versions for file ais/ai-00326.txt

--- ais/ai-00326.txt	2003/05/24 00:51:42	1.1
+++ ais/ai-00326.txt	2003/07/15 20:41:55	1.2
@@ -1,4 +1,4 @@
-!standard 03.10.01   (02)                            03-02-11  AI95-00326/01
+!standard 03.10.01   (02)                            03-07-15  AI95-00326/02
 !standard 03.10.01   (04)
 !standard 03.10.01   (05)
 !standard 03.10.01   (08)
@@ -7,6 +7,8 @@
 !standard 03.10.01   (11)
 !standard J.11       (00)
 !class amendment 02-02-06
+!status Amendment 200Y 03-07-15
+!status ARG Approved 10-0-1  03-07-15
 !status work item 02-12-13
 !status received 02-02-06
 !priority Medium
@@ -17,7 +19,7 @@
 A concept of a "tagged incomplete" type is introduced, which is a type that has
 the same restrictions as an incomplete type except that it may also be used for
-a formal or actual parameter.
+a formal parameter.
@@ -28,8 +30,8 @@
 reference, there is no implementation difficulty in allowing them to be used as
 parameters even when the full definition of the type is not available.  Hence,
 it makes sense to relax the rule for using incomplete types that are known to
-be tagged, to allow them as formal and actual parameters, since from a code
-generation point of view they are essentially equivalent to access parameters.
+be tagged, to allow them as formal parameters, since from a code generation
+point of view they are essentially equivalent to access parameters.
@@ -41,8 +43,7 @@
 If the words IS TAGGED appear, the type is a tagged incomplete type. Otherwise,
 the type is a non-tagged incomplete type. In addition to places where a
 (non-tagged) incomplete type may be used, a tagged incomplete type may be used
-as a formal parameter type, and as an actual parameter that is a dereference of
-an access-to-tagged-incomplete value. The attribute 'Class is defined for
+as a formal parameter type. The attribute 'Class is defined for
 (specific) tagged incomplete types. (The use of 'Class with non-tagged
 incomplete types is considered obsolescent; such non-tagged incomplete types
 must be completed with a tagged type.) The class-wide type denoted by the Class
@@ -228,3 +229,97 @@
 matter which of those proposals is adopted.
+From: Randy Brukardt
+Sent: Tuesday, July 15, 2003  2:25 PM
+In Toulouse, we discussed whether we could allow dereferences of tagged
+incomplete types. In general, the answer is no, because we cannot know where
+tags and discriminants are going to be stored in the completing type. (If
+the type is completed in the body, for instance.)
+The conversation in Toulouse focused on dispatching calls. Clearly, we
+cannot allow dispatching calls because we don't know where the tag is stored
+(presuming the implementation allows positioning it, as Rational Apex and
+Janus/Ada do).
+However, there is no problem with class-wide calls, and these could be
+useful. The key is that we can only allow "whole-object" dereferences when
+the dereference is immediately passed as a reference parameter. This would
+look something like:
+      package Typ is
+          type T is tagged;
+          type AT is access all T;
+          procedure Op1 (Obj : in out T'Class);
+          procedure Op2 (Obj : in out T);
+          ...
+      end Typ;
+      with Typ;
+      procedure User is
+          ...
+          P : Typ.AT := ...;
+          ...
+          Typ.Op1 (P.all); -- Allowed? (No implementation problem).
+          Typ.Op2 (P.all); -- Can't allow (don't know where the tag is).
+          ...
+      end User;
+Note that Op1 could be used as a work-around to implement Op2 if that was
+necessary (as the body of Typ.Op1 certainly could dispatch to Op2).
+This rule would be on the messy side (it pretty much could only allow
+dereferences when used as a non-dispatching actual parameter) and I haven't
+tried to figure out the wording.
+Should we pursue this, or leave that AI without any means of making a call?
+From: Randy Brukardt
+Sent: Tuesday, July 15, 2003  2:41 PM
+I neglected to mention that class-wide parameters would be the most likely
+way that a tagged incomplete type would be used from a limited with (you
+almost always should avoid non-dispatching specific tagged parameters,
+because they cause trouble if there is an extension). So, such a class-wide
+call may not be rare:
+    package Office is
+        type Department is tagged private;
+        type Dept_Ptr is access all Department'Class;
+    private
+        ...
+    end Office;
+    limited with Office;
+    package Employees is
+        type Employee is tagged private;
+        type Emp_Ptr is access all Employee'Class;
+        procedure Assign_Employee(E : in out Employee;
+                                  D : in out Office.Department'Class);
+        ...
+        function Current_Department(D : in Employee) return Office.Dept_Ptr;
+    private
+        ...
+    end Employees;
+    with Employees, Repository;
+    procedure RRS is
+        Randy, Ian, Isaac : Employees;
+    begin
+        -- Add a new employee in Randy's department:
+        Repository.Read (Randy);
+        Employees.Assign_Employee (Isaac, Employees.Current_Department (Randy).all);
+        Repository.Write (Isaac);
+    end RRS;
+The call to Assign_Employee is illegal for a tagged incomplete type. We'd
+have to with Office to make it legal, which is annoying, since this has
+little to do with Office. (And, if we adopt a special rule to make it legal
+here, which we've discussed, then it ought to be legal for tagged incomplete
+as well -- otherwise, we'd have a weird inconsistency.)

Questions? Ask the ACAA Technical Agent