comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Extended revelation
Date: 2000/01/31
Date: 2000-01-31T00:00:00+00:00	[thread overview]
Message-ID: <3Cfl4.1352$gC3.64742@newsread1.prod.itd.earthlink.net> (raw)
In-Reply-To: 873q03$alb$1@nnrp1.deja.com

In article <873q03$alb$1@nnrp1.deja.com> , Jean-Marc Bourguet 
<bourguet@my-deja.com>  wrote:

> My problem is that in one of the child package, I'd like to make
> public one of the private type (T). I had though that
>
>  type T1 is private;
>     private
>  subtype T1 is T;
>
> but that's not valid.

No, you can't implement the full view of a private type as a subtype.


> As renanimg does not apply to types I can't see
> an easy way to do it. Currently I'm using
>
>  type T1 is private;
>     private
>  type T1 is new T;

Yes, this is one way to do it.  One issue with this solution is that
there's no clean separation between public and private namespaces.  That
is, certain (usually predefined) operations can become directly visible
at the point of declaration of the full view (here, T), and they may
conflict with operations declared for the partial view.

The best thing to do is always implement the full view of a private type
as a record:

package P is

  type T1 is private;

private

  type T1 is
    record
      O : T;
    end record;

end P;

Now there is no problem.

Indeed, I consider it a design flaw in the language, in that it allows
you to implement the full view as something other than a record.  I wish
they had designed Ada83 private types the same way they designed Ada95
tagged types.


> I've also considered exporting T from the parent package, but neither
> solution please me.

I'm not sure what you mean by this.

Matt




  parent reply	other threads:[~2000-01-31  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-31  0:00 Extended revelation Jean-Marc Bourguet
2000-01-31  0:00 ` Jean-Marc Bourguet
2000-01-31  0:00   ` Matthew Heaney
2000-01-31  0:00     ` Vladimir Olensky
2000-02-01  0:00   ` Richard D Riehle
2000-01-31  0:00 ` Matthew Heaney [this message]
2000-01-31  0:00 ` Mark Lundquist
replies disabled

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