comp.lang.ada
 help / color / mirror / Atom feed
From: Philippe Tarroux <philippe.tarroux@limsi.fr>
Subject: tagged type as generic parameter
Date: Thu, 03 Jan 2008 16:20:48 +0100
Date: 2008-01-03T16:20:48+01:00	[thread overview]
Message-ID: <fliudg$14v$1@news2.u-psud.fr> (raw)

Hi everybody,

I wrote the following packages:


generic
   type Data is tagged private;  -- In order to be able to build lists 
of items of this type
package List is

   type List (<>) is private;

private
   type Item;
   type Item_Ptr is access Item;
   type Item is new Data with record      -- Line 22
      Next : Item_Ptr;
   end record;
  
   type List_Head is tagged record
      Head : Item_Ptr := null;
   end record;

   type List is access List_Head;
end List;

-----------------------------------
package data_handler is

   type Data is tagged private;
  
   function A_Data(V : Integer) return Data;
   procedure Print (D : Data);
  
private
  
   type Data is tagged record
      Value : Integer;
   end record;

end data_handler;

-------------------------------------------

with List;
with Data_Handler;
use Data_Handler;

package data_list is

   package My_List is new List (Data_Handler.Donn�es); 

end data_list;

When i try to instantiate the last package (data_list) i get the 
following error:

data_list.ads:7:04: instantiation error at list.ads:22
data_list.ads:7:04: type must be declared abstract or "a_data" overridden
data_list.ads:7:04: "a_data" has been inherited at list.ads:22, instance 
at line 7
data_list.ads:7:04: "a_data" has been inherited from subprogram at 
data_handler.ads:5

I suspect the problem is due to the derivation of Item from Data at line 
22 of list.ads during the instantiation of the generic but I don't 
really understand why and i don't understand why the problem arises with 
the function A_Data and not with the procedure Print.

OS : W2K
GCC version 4.1.3 20070403 for GNAT GPL 2007

Thank and best regards

Philippe Tarroux






             reply	other threads:[~2008-01-03 15:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-03 15:20 Philippe Tarroux [this message]
2008-01-03 15:51 ` tagged type as generic parameter Dmitry A. Kazakov
2008-01-03 16:22   ` Adam Beneschan
2008-01-03 16:58     ` Dmitry A. Kazakov
2008-01-03 17:47       ` Jean-Pierre Rosen
2008-01-03 18:13         ` Pascal Obry
2008-01-03 19:20         ` Dmitry A. Kazakov
2008-01-03 21:37         ` Jeffrey R. Carter
2008-01-04 13:08           ` Philippe Tarroux
2008-01-04 15:03             ` Jean-Pierre Rosen
2008-01-04 13:08   ` Philippe Tarroux
2008-01-04 13:22     ` Georg Bauhaus
2008-01-04 15:38       ` Philippe Tarroux
2008-01-04 14:17     ` Dmitry A. Kazakov
replies disabled

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