comp.lang.ada
 help / color / mirror / Atom feed
* Re: losing visibility
  2000-10-23  2:32 losing visibility tmoran
@ 2000-10-23  0:00 ` Pascal Obry
  2000-10-24  0:00 ` Tucker Taft
  1 sibling, 0 replies; 3+ messages in thread
From: Pascal Obry @ 2000-10-23  0:00 UTC (permalink / raw)



tmoran@bix.com writes:

> Would someone please refresh my memory as to why "nucleus" should
> become invisible in:

I found nothing in the ARM about this issue. It could be a compiler bug, with
what compiler did you try this ? GNAT does reject this...

We can find good arguments either way, so definitly we need to find something
in the RM to be sure :)

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"




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

* losing visibility
@ 2000-10-23  2:32 tmoran
  2000-10-23  0:00 ` Pascal Obry
  2000-10-24  0:00 ` Tucker Taft
  0 siblings, 2 replies; 3+ messages in thread
From: tmoran @ 2000-10-23  2:32 UTC (permalink / raw)


Would someone please refresh my memory as to why "nucleus" should
become invisible in:

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;



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

* Re: losing visibility
  2000-10-23  2:32 losing visibility tmoran
  2000-10-23  0:00 ` Pascal Obry
@ 2000-10-24  0:00 ` Tucker Taft
  1 sibling, 0 replies; 3+ messages in thread
From: Tucker Taft @ 2000-10-24  0:00 UTC (permalink / raw)


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




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

end of thread, other threads:[~2000-10-24  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-23  2:32 losing visibility tmoran
2000-10-23  0:00 ` Pascal Obry
2000-10-24  0:00 ` Tucker Taft

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