comp.lang.ada
 help / color / mirror / Atom feed
From: Tucker Taft <stt@averstar.com>
Subject: Re: losing visibility
Date: 2000/10/24
Date: 2000-10-24T20:32:10+00:00	[thread overview]
Message-ID: <39F5F1CA.AC29AF5B@averstar.com> (raw)
In-Reply-To: WqNI5.348353$i5.5348409@news1.frmt1.sfba.home.com

tmoran@bix.com wrote:
> 
> Would someone please refresh my memory as to why "nucleus" should
> become invisible in:

Because grandkid is declared outside the immediate
scope of "child," it inherits only operations that are 
visible outside of child.  The fact that the body
of package four knows more about the parent of "child"
is irrelevant.  It doesn't have visibility on the
nucleus field of child, and grandkid doesn't inherit visibility
on the nucleus field.

The first paragraph of 7.3.1 is the key one, and here is the
key sentence:
   ... Such private operations are available only inside
   the declarative region of the package or generic package.

".nucleus" is a private operation on child, and it is
not visible outside of package three, because it is not
available until after the word "private" (when the full
type of the parent becomes visible).

-Tucker Taft
-------------------------
 
> 
> package one is
>   type root is tagged private;
> private
>   type root is tagged record
>     nucleus : integer;
>   end record;
> end one;
> 
> package one.two is
>   package three is
>     type child is new one.root with private;
>   private
>     type child is new one.root with record
>       electrons : integer;
>     end record;
>   end three;
> 
>   package four is
>     type grandkid is new three.child with null record;
>     procedure initialize(x : in out grandkid);
>   end four;
> 
> end one.Two;
> 
> package body one.Two is
>   package body four is
>     procedure initialize(x : in out grandkid) is
>     begin
>       x.nucleus := 1;      -- <<<<<<<<<<<<<< BAD nucleus not visible
>     end initialize;
>   end four;
> 
>   y : four.grandkid;
> 
> begin
>   one.root(y).nucleus := 2;  -- <<<<<<<<<<<<<< OK, nucleus visible
>   y.nucleus := 3;            -- <<<<<<<<<<<<<< BAD, nucleus not visible
> 
> end one.Two;
> 
> with one.Two;
> procedure testvis is
> begin null;end testvis;

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Commercial Division, AverStar (formerly Intermetrics)
(http://www.averstar.com/services/IT_consulting.html)  Burlington, MA  USA




      parent reply	other threads:[~2000-10-24  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-10-23  2:32 losing visibility tmoran
2000-10-23  0:00 ` Pascal Obry
2000-10-24  0:00 ` Tucker Taft [this message]
replies disabled

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