comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: Generic children, instances and visibility...
Date: 1997/04/09
Date: 1997-04-09T00:00:00+00:00	[thread overview]
Message-ID: <334BA5F2.4111@gsfc.nasa.gov> (raw)
In-Reply-To: JSA.97Apr8212412@alexandria


Jon asks about visibility into a private type within a generic body. I
constructed a compilable example:

package Parent is
   type T is abstract tagged limited private;
private
   type T is abstract tagged limited record
      F : Integer;
   end record;
end Parent;

generic
   type Nt is new T with private;
package Parent.Child is

   procedure Foo (Object : in out Nt);

end Parent.Child;

package body Parent.Child is
   procedure Foo (Object : in out Nt)
   is begin
      Object.F := 1;
   end Foo;
end Parent.Child;

Jon then tries to instantiate this in two ways:

with Parent.Child;
with Inst_Types;
procedure test is
   package PC_Inst is new Parent.Child (Inst_Types.It);
begin
   null;
end test;

with Parent.Child;
with Inst_Types;
package Parent.PC_Inst is new Parent.Child (Inst_Types.It);

gnat says neither case allows visibility:

gnatmake test.adb
gcc -c test.adb
test.adb:4:04: instantiation error at parent-child.adb:4
test.adb:4:04: undefined selector for type "It" defined at
inst_types.ads:3
gnatmake: "test.adb" compilation error


gnatmake parent-pc_inst.ads
gcc -c parent-pc_inst.ads
parent-pc_inst.ads:3:01: instantiation error at parent-child.adb:4
parent-pc_inst.ads:3:01: undefined selector for type "It" defined at
inst_types.ads:3
gnatmake: "parent-pc_inst.ads" compilation error

So, hoping that a private child would have visibility, I tried a third
variation:

with Parent.Child;
with Inst_Types;
private package Parent.Test is
   type It is new Parent.T with null record;

   package PC_Inst is new Parent.Child (Inst_Types.It);

end Parent.Test;

It would seem that no generic can see inside type It; it is a limited
private type, period.
-- 
- Stephe




  reply	other threads:[~1997-04-09  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-09  0:00 Generic children, instances and visibility Jon S Anthony
1997-04-09  0:00 ` Stephen Leake [this message]
1997-04-09  0:00   ` Jon S Anthony
1997-04-12  0:00     ` Tucker Taft
1997-04-13  0:00     ` Jon S Anthony
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox