comp.lang.ada
 help / color / mirror / Atom feed
* Incomplete types used with generics
@ 2015-05-11 22:37 Jeremiah
  2015-05-12  1:43 ` Randy Brukardt
  2015-05-12 21:49 ` Randy Brukardt
  0 siblings, 2 replies; 9+ messages in thread
From: Jeremiah @ 2015-05-11 22:37 UTC (permalink / raw)


One of the things I read about with ada2012 is the ability to use incomplete types as generic parameters.  However, I am having some trouble implementing them.  I'm using GNAT GPL 2014 and have the following dumbed down packages:

generic
   type Item_Type is tagged limited private;
   type Item_Access is access Item_Type;
package Test_Generic is
   type Test is tagged record
      Ref : Item_Access := null;
   end record;
end Test_Generic;


with Test_Generic;

package Test_Nodes is

   type Node3_ptr is null record;

   type Node1_Type is tagged record
      value : Integer := 0;
   end record;
   type Node1_Access is access Node1_Type;

   package N1 is new Test_Generic(Node1_Type,Node1_Access);

   type Node2_Type is tagged;
   type Node2_Access is access Node2_Type;

   package N2 is new Test_Generic(Node2_Type,Node2_Access);

   type Node2_Type is tagged record
      value : Integer := 1;
      Test  : N2.Test;
   end record;

end Test_Nodes;

However, the line 
package N2 is new Test_Generic(Node2_Type,Node2_Access);

fails with:  premature use of incomplete type

I *think* the generic parameter "type Item_Type is tagged limited private;" is considered incomplete as is "type Node2_Type is tagged;".

What am I missing?

Ada2012 incomplete types with generics reference:
http://www.ada-auth.org/standards/12rat/html/Rat12-4-3.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-05-14 20:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-11 22:37 Incomplete types used with generics Jeremiah
2015-05-12  1:43 ` Randy Brukardt
2015-05-12  7:33   ` Simon Wright
2015-05-12 11:48     ` Jeremiah
2015-05-12 11:46   ` Jeremiah
2015-05-12 21:49 ` Randy Brukardt
2015-05-12 23:19   ` Jeremiah
2015-05-14  1:14     ` Randy Brukardt
2015-05-14 20:48       ` Jeremiah

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