CVS difference for ais/ai-00218.txt

Differences between 1.12 and version 1.13
Log of other versions for file ais/ai-00218.txt

--- ais/ai-00218.txt	2002/05/25 03:42:17	1.12
+++ ais/ai-00218.txt	2003/01/23 22:02:36	1.13
@@ -1,5 +1,5 @@
 !standard 8.3(26)                                      01-09-11  AI95-00218/06
-!status Amendment 200Y 02-01-17
+!status work item 02-10-15
 !class amendment 99-03-23
 !status WG9 approved 01-10-05
 !status ARG approved 7-0-1  01-05-18
@@ -455,6 +455,89 @@
 replies that they are not defined that way in the RM. Moreover, it is very
 useful semantics to localize the effects of the pragma, as library code might
 be part of the partition, but not adhere to the use of the Overrides pragma.
+
+*************************************************************
+
+!from Randy Brukardt 03-01-23
+
+A problem was noted with this AI during the Bedford ARG meeting. If you have
+a private type, you may not know whether an operation is overridding. Moreover,
+this information would be a (minor) violation a privacy. Consider:
+
+pragma Explicit_Overridding;
+package P is
+    type T is private;
+    function "+" (Left, Right: T) return T; -- Not overriding here.
+private
+   type T is range 0 .. 100;     -- "+" overrides here.
+end P;
+
+You also can have a similar case for tagged types:
+
+package P is
+   type T is new T1;
+   procedure Foo; -- Not overridding here.
+private
+   type T is new T2;
+   procedure Foo; -- Does override here.
+end P;
+
+I've looked at three solutions for this:
+
+The first solution is to add full profiles to the Overrides pragma, so we can
+separate them from the declarations. Then, we also have to change the location
+where the check occurs (probably to the freezing point of the type). In this
+example, that would look like:
+
+pragma Explicit_Overridding;
+package P is
+   type T is private;
+   function "+" (Left, Right: T) return T;
+private
+   type T is range 0 .. 100;     -- "+" overrides
+   pragma Overrides ("+" (Left, Right: T) return T);
+end P;
+
+Note that this is completely new syntax for pragmas; existing compilers could
+not handle it. And its ugly.
+
+Another alternative is to allow redeclarations of operations simply to provide
+a place to hang these pragmas:
+
+pragma Explicit_Overridding;
+package P is
+   type T is private;
+   function "+" (Left, Right: T) return T;
+   pragma Optional_Overriding("+"); -- So there is no check here.
+private
+   type T is range 0 .. 100;     -- "+" overrides
+   function "+" (Left, Right: T) return T; -- A redeclaration.
+   pragma Overrides ("+");
+end P;
+
+Having all of these "Optional_Overriding" pragmas is annoying. And, again,
+redeclarations is a new feature that existing compilers could not swallow.
+
+The third choice is to move the check to the freezing point and use
+redeclarations. In this case, the original declaration's overriding state is
+overridden later:
+
+pragma Explicit_Overridding;
+package P is
+   type T is private;
+   function "+" (Left, Right: T) return T;
+private
+   type T is range 0 .. 100;     -- "+" overrides
+   function "+" (Left, Right: T) return T; -- A redeclaration.
+   pragma Overrides ("+");
+   -- The check that "+" is overridding is made here.
+end P;
+
+Again, we have the new concept of redeclaration.
+
+The main advantage of the pragmas only proposal was that no new syntax or
+semantics (other than the check itself) is needed. That no longer appears to
+be the case, so I have reluctantly abandoned this alternative of the AI.
 
 *************************************************************
 

Questions? Ask the ACAA Technical Agent