comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: Private Children
Date: 1999/06/21
Date: 1999-06-21T00:00:00+00:00	[thread overview]
Message-ID: <376E9EEB.322A3F39@averstar.com> (raw)
In-Reply-To: m3yahd4bet.fsf@mheaney.ni.net

Matthew Heaney wrote:
> 
> On 21 Jun 1999 17:04, Tucker Taft <stt@averstar.com> wrote:
> 
> > To answer the question posed by this new question, the answer
> > given by Dale was correct, that private children provide "compilation
> > privacy."  If you want to allow something to be "with"ed by public
> > children's specs, but contain content that is only visible to
> > the private part of the child's spec, the following idiom works:
> >
> >    package Mostly_Private is
> >    private
> >        ... -- Declarations visible only in private part of other public
> >        ...  -- siblings
> >    end Mostly_Private;
> >
> > That is, put the entire set of declarations in the private part
> > of a public child.
> 
> I did what I think you wanted me to do, but got this error message:
> 
> gcc -c -gnatc /home/matt/p-c2.ads
> p-c2.ads:9:23: "I1" is not a visible entity of "C1"
> 
> Is this a compiler bug, or did I misunderstand what you said?
> 
> Can a package really see the private part of its sibling?  I thought
> that only your own children could see your private part.

Oops, right you are.  The "idiom" I was misremembering was actually to
create an extra level in the hierarchy, with all of the public
children made into public children of this intermediate level,
with the intermediate level spec having only a private part.
You could then use library unit renaming to hide the presence
of this intermediate level, if you wanted to.  I believe Robert
Eachus suggested this approach originally.

E.g.:
    package P.Hidden_Level is
    private
       ... -- private stuff
    end;

    package P.Hidden_Level.C1 is
      ...
    private
      ...  -- can see private decls of P.Hidden_Level
    end;

    with P.Hidden_Level.C1;
    package P.C1 renames P.Hidden_Level.C1;

Sorry for the confusion.

-Tuck

> Or did you mean for me to put I1 in the private part of P, not P.C1?
> 
> --STX
> package P is
> 
>    pragma Pure;
> 
> end P;
> 
> package P.C1 is
> private
> 
>   I1 : Integer;
> 
> end P.C1;
> 
> with P.C1;
> package P.C2 is
> 
>   I2 : Integer;
> 
> private
> 
>   I3 : Integer := P.C1.I1;
> 
> end P.C2;

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




  reply	other threads:[~1999-06-21  0:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-20  0:00 Private Children Matthew Heaney
1999-06-21  0:00 ` Dale Stanbrough
1999-06-21  0:00 ` Ted Dennison
1999-06-21  0:00   ` Tucker Taft
1999-06-21  0:00     ` Matthew Heaney
1999-06-21  0:00     ` Matthew Heaney
1999-06-21  0:00       ` Tucker Taft [this message]
1999-06-22  0:00         ` Richard D Riehle
1999-06-22  0:00           ` Dale Stanbrough
1999-06-22  0:00             ` Richard D Riehle
1999-06-22  0:00             ` Matthew Heaney
1999-06-23  0:00               ` Dale Stanbrough
1999-06-23  0:00                 ` Matthew Heaney
1999-06-23  0:00                   ` Dale Stanbrough
1999-06-23  0:00                     ` Richard D Riehle
1999-06-23  0:00                       ` Vladimir Olensky
1999-06-23  0:00                         ` Richard D Riehle
1999-06-24  0:00                           ` Hyman Rosen
1999-06-24  0:00                             ` Richard D Riehle
1999-06-23  0:00                       ` John Duncan
1999-06-24  0:00                       ` Dale Stanbrough
1999-06-25  0:00   ` Robert Dewar
replies disabled

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