comp.lang.ada
 help / color / mirror / Atom feed
* Package Hierarchy and Private functions
@ 2009-03-18 12:22 RasikaSrinivasan
  2009-03-18 12:42 ` Maciej Sobczak
  2009-03-18 14:19 ` Robert A Duff
  0 siblings, 2 replies; 4+ messages in thread
From: RasikaSrinivasan @ 2009-03-18 12:22 UTC (permalink / raw)


Friends

Supposing we have 2 packages like :

package P is
  type Pvt_T is private ;
private
  type Pvt_T is ... ;
  procedure Pvt_Proc(p : in out Pvt_T) ;
end P ;

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

package P.C is
....
end P.C ;

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

Is there a way for P.C to access Pvt_Proc (instead of making it
public). I guess this may be analogous to protected in C++?

Does P.C has a special relationship to P?

any pointers/advice appreciated. thanks, srini



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Package Hierarchy and Private functions
  2009-03-18 12:22 Package Hierarchy and Private functions RasikaSrinivasan
@ 2009-03-18 12:42 ` Maciej Sobczak
  2009-03-18 12:56   ` Srini -
  2009-03-18 14:19 ` Robert A Duff
  1 sibling, 1 reply; 4+ messages in thread
From: Maciej Sobczak @ 2009-03-18 12:42 UTC (permalink / raw)


On 18 Mar, 13:22, "RasikaSriniva...@gmail.com"
<RasikaSriniva...@gmail.com> wrote:

> Supposing we have 2 packages like :
>
> package P is
>   type Pvt_T is private ;
> private
>   type Pvt_T is ... ;
>   procedure Pvt_Proc(p : in out Pvt_T) ;
> end P ;
>
> ---------------------
>
> package P.C is
> ....
> end P.C ;
>
> ------------------
>
> Is there a way for P.C to access Pvt_Proc

Yes. Just do it.

> I guess this may be analogous to protected in C++?

Ada's private *is* analogous to protected in C++.

> Does P.C has a special relationship to P?

Yes, it can see its private (which means protected) parts.

--
Maciej Sobczak * www.msobczak.com * www.inspirel.com

Database Access Library for Ada: www.inspirel.com/soci-ada



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Package Hierarchy and Private functions
  2009-03-18 12:42 ` Maciej Sobczak
@ 2009-03-18 12:56   ` Srini -
  0 siblings, 0 replies; 4+ messages in thread
From: Srini - @ 2009-03-18 12:56 UTC (permalink / raw)


Thanks. The doubt came due to an error message that I misunderstood.
srini

On Mar 18, 8:42 am, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
> On 18 Mar, 13:22, "RasikaSriniva...@gmail.com"
>
>
>
> <RasikaSriniva...@gmail.com> wrote:
> > Supposing we have 2 packages like :
>
> > package P is
> >   type Pvt_T is private ;
> > private
> >   type Pvt_T is ... ;
> >   procedure Pvt_Proc(p : in out Pvt_T) ;
> > end P ;
>
> > ---------------------
>
> > package P.C is
> > ....
> > end P.C ;
>
> > ------------------
>
> > Is there a way for P.C to access Pvt_Proc
>
> Yes. Just do it.
>
> > I guess this may be analogous to protected in C++?
>
> Ada's private *is* analogous to protected in C++.
>
> > Does P.C has a special relationship to P?
>
> Yes, it can see its private (which means protected) parts.
>
> --
> Maciej Sobczak *www.msobczak.com*www.inspirel.com
>
> Database Access Library for Ada:www.inspirel.com/soci-ada




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Package Hierarchy and Private functions
  2009-03-18 12:22 Package Hierarchy and Private functions RasikaSrinivasan
  2009-03-18 12:42 ` Maciej Sobczak
@ 2009-03-18 14:19 ` Robert A Duff
  1 sibling, 0 replies; 4+ messages in thread
From: Robert A Duff @ 2009-03-18 14:19 UTC (permalink / raw)


"RasikaSrinivasan@gmail.com" <RasikaSrinivasan@gmail.com> writes:

> Supposing we have 2 packages like :
>
> package P is
>   type Pvt_T is private ;
> private
>   type Pvt_T is ... ;
>   procedure Pvt_Proc(p : in out Pvt_T) ;
> end P ;
>
> ---------------------
>
> package P.C is
> ....
> end P.C ;
>
> ------------------
>
> Is there a way for P.C to access Pvt_Proc (instead of making it
> public).

The contents of P's private part are visible in the private part and the
body of P.C.  It's similar to putting a package C nested inside P,
but not exactly the same.

If you make P.C into a private child package:

private package P.C is
...
end P.C ;

then the contents of P's private part are visible in ALL of P.C,
including its visible part.

> I guess this may be analogous to protected in C++?

Yeah, sort of.

- Bob



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-18 14:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-18 12:22 Package Hierarchy and Private functions RasikaSrinivasan
2009-03-18 12:42 ` Maciej Sobczak
2009-03-18 12:56   ` Srini -
2009-03-18 14:19 ` Robert A Duff

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