comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: Declaration of private type Containers
Date: Fri, 30 May 2008 14:21:52 +0200
Date: 2008-05-30T14:21:52+02:00	[thread overview]
Message-ID: <9hro1g.ni4.ln@hunter.axlog.fr> (raw)
In-Reply-To: <6d6feee1-fe69-4d19-9745-4748d341a56e@r66g2000hsg.googlegroups.com>

alexander.kleppe@web.de a �crit :
> Hi all,
> 
> I'm relatively new to Ada. I have a problem, which seems pretty basic
> to me. Thus, I guess you guys have a easy solution ready.
> The only thing I want to do is to  declare a list package, whose
> Element_Type is of a private record type:
> 
> package A is
> 
> type My_Type is private
> 
> package My_Type_Lists is new Ada.Containers.Doubly_Linked_List
>      (Element_Type	=> My_Type);
> 
> private
> 
> type My_Type is
> record
> ...
> end record;
> 
> end A;
> 
> 
> GNAT compiler says, this is a "premature use of private type", which I
> accept. 
Glad to hear that you accept it. The ARG tried hard to allow something 
like this, and eventually gave up under the pressure of an exponentially 
growing mountain of cans of worms...

If My_Type_Lists is not used within My_Type itself, the easiest way is 
to instantiate it as a child package:
package A.My_Type_Lists is new Ada.Containers.Doubly_Linked_List
       (Element_Type	=> My_Type);

-- 
---------------------------------------------------------
            J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



  parent reply	other threads:[~2008-05-30 12:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-30 11:49 Declaration of private type Containers alexander.kleppe
2008-05-30 12:05 ` Dmitry A. Kazakov
2008-05-30 12:21 ` Jean-Pierre Rosen [this message]
2008-05-30 13:59   ` alexander.kleppe
2008-05-30 14:25     ` Jean-Pierre Rosen
2008-05-30 16:00     ` Adam Beneschan
2008-05-31  2:04     ` Steve
2008-05-31  5:28   ` Randy Brukardt
2008-05-30 20:27 ` Matthew Heaney
2008-06-04 15:40   ` alexander.kleppe
replies disabled

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