comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: Declaration of private type Containers
Date: Fri, 30 May 2008 19:04:07 -0700
Date: 2008-05-30T19:04:07-07:00	[thread overview]
Message-ID: <qc6dnbNVa96ZL93VnZ2dnUVZ_o_inZ2d@comcast.com> (raw)
In-Reply-To: 8910e931-889f-4617-a249-71b5016a13e2@r66g2000hsg.googlegroups.com

<alexander.kleppe@web.de> wrote in message 
news:8910e931-889f-4617-a249-71b5016a13e2@r66g2000hsg.googlegroups.com...
> Thanks so far.
> So if I understand you right, there is no way to declare the list
> package within the spec file of My_Type beside declaring My_Type
> public? ...

That depends on how you define public.  I don't think Ada has a definition 
of public.

In Ada if you're going to use a type it must be visible to the code that 
uses it.  For private types, to be able to use the type the declaration must 
be visible, but not the definition.  So when you have:

package A is

  type My_Record is private;
  package My_List is new ListPackage( My_Record );

private

  type My_Record is
    record
        field : Field_Type;
    end record;

end A;

In order to define MyList as a list of My_Record's, My_Record must be 
visible, but the defintion of My_Record may still be private.

In essance users of Package A will know that My_Record exists, and they will 
know that My_List is a generic package that is instantiated for My_Record, 
buty they won't know what My_Record looks like (they can't see into the 
private section).

You may already understand this, but I wasn't sure by your post.

Regards,
Steve
(The Duck)

> ... I suppose I have to source out the subprograms using the list
> instances in their parameter list out of package A as well...
> So my solution now is a new package spec and body called A.Containers,
> which contains all the container packages and subprograms formerly
> declared in A (which brought the error with private types). The
> alternative would be your suggestion to declare the package as
> A.My_Types_List in package B. Hope that's what you meant, otherwise
> please correct me. 





  parent reply	other threads:[~2008-05-31  2:04 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
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 [this message]
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