CVS difference for ai12s/ai12-0005-1.txt
--- ai12s/ai12-0005-1.txt 2019/11/08 04:28:19 1.31
+++ ai12s/ai12-0005-1.txt 2019/11/15 05:18:40 1.32
@@ -1640,7 +1640,147 @@
***************************************************************
-Editor's note (October 28, 2019): All of the items above this
+From: Pascal Pignard
+Sent: Tuesday, October 15, 2019 2:18 PM
+
+[From private mail.]
+
+I've read the AARM 202x draft 22 (text version).
+
+Section 7.3 Private Types and Private Extensions, I've found:
+7.w/2 procedure Bar (X : T1'Class) is
+ begin
+ Pkg.Foo (X); -- should call Foo #1 or an override thereof
+ end;
+
+GNAT complains with: error: expected type "Ifc"
+
+I propose the change:
+ Pkg.Foo (Pkg.Ifc'Class(X)); -- should call Foo #1 or an override thereof
+
+It compiles but I when I execute:
+7.x/2 begin
+ Pkg.Foo (Pkg.Ifc'Class (P_Client.X)); -- should call Foo #2
+ Bar (T1'Class (P_Client.X));
+ end P;
+I got:
+Foo #2
+Foo #2
+
+Is it correct?
+
+In order to get Foo #1, I execute:
+ X:T1;
+ begin
+ Pkg.Foo (Pkg.Ifc'Class(X));
+ Bar (X);
+ end P;
+==
+Foo #1
+Foo #1
+
+
+PS: I make a little change in the AARM example to avoid illegal statement.
+See full source code:
+
+with Ada.Text_IO;
+procedure Test40 is
+
+-- Section_7_3_Paragraph_7q
+
+ package P is
+ package Pkg is
+ type Ifc is interface;
+ procedure Foo (X : Ifc) is abstract;
+ end Pkg;
+
+ type Parent_1 is tagged null record;
+
+ -- type T1 is new Parent_1 with private;
+ type T1 is new Parent_1 and Pkg.Ifc with private; --@@ Change to avoid further illegal type declaration
+ private
+ type Parent_2 is new Parent_1 and Pkg.Ifc with null record;
+ procedure Foo (X : Parent_2); -- Foo #1
+
+ -- type T1 is new Parent_2 with null record; -- Illegal.
+ type T1 is new Parent_2 with null record;
+ end P;
+
+ --@ with P;
+ package P_Client is
+ type T2 is new P.T1 and P.Pkg.Ifc with null record;
+ procedure Foo (X : T2); -- Foo #2
+ X : T2;
+ end P_Client;
+
+ package body P_Client is
+ procedure Foo (X : T2) is
+ begin
+ Ada.Text_IO.Put_Line ("Foo #2");
+ end Foo; -- Foo #2
+ end P_Client;
+
+ --@ with P_Client;
+ package body P is
+ --@ ...
+ procedure Foo (X : Parent_2) is
+ begin
+ Ada.Text_IO.Put_Line ("Foo #1");
+ end Foo; -- Foo #1
+
+ procedure Bar (X : T1'Class) is
+ begin
+ Pkg.Foo (Pkg.Ifc'Class (X)); -- should call Foo #1 or an override thereof
+ end Bar;
+
+ X : T1;
+
+ begin
+ Pkg.Foo (Pkg.Ifc'Class (P_Client.X)); -- should call Foo #2
+ Bar (T1'Class (P_Client.X));
+ Pkg.Foo (Pkg.Ifc'Class (X));
+ Bar (X);
+ end P;
+
+begin
+ null;
+end Test40;
+
+***************************************************************
+
+From: Randy Brukardt
+Sent: Thursday, November 14, 2019 9:29 PM
+
+Eliminating the illegal line eliminates the point of the example, so I don't
+think it is particularly relevant what the rest of it does, or what it
+executes if it is modified to be legal.
+
+> I propose the change:
+> Pkg.Foo (Pkg.Ifc'Class(X)); -- should call Foo #1 or an
+> override thereof
+
+I worry this would be confusing for this example, but it can't be helped.
+Part of the point is that identical calls could have different results
+depending on visibility, and I suppose this change makes it even more obvious.
+
+> It compiles but I when I execute:
+> 7.x/2 begin
+> Pkg.Foo (Pkg.Ifc'Class (P_Client.X));
+> -- should call Foo #2
+> Bar (T1'Class (P_Client.X));
+> end P;
+> I got:
+> Foo #2
+> Foo #2
+>
+> Is it correct?
+
+Yes, once you make the interface visible, normal overriding occurs. This isn't
+very interesting.
+
+***************************************************************
+
+Editor's note (November 14, 2019): All of the items above this
marker have been included in the working version of the AARM.
****************************************************************
Questions? Ask the ACAA Technical Agent