comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Visibility Rules For Children
Date: 1998/10/26
Date: 1998-10-26T00:00:00+00:00	[thread overview]
Message-ID: <m34sss6juk.fsf@mheaney.ni.net> (raw)

What are the visibility rules for children?

In the code fragment below, I have a procedure, GC, that is a child of
parent package GP.  The child is a generic that imports generic formal
type NT, derived from type T, declared in the parent package GP.

The parent type T (and its derived type NT, of course) has an Integer
component I.  All the child operation does is set the value of that
component.

Yet, the compiler is telling me that the child can't see the component I
of NT:

(start of message)
q.ads:8:04: instantiation error at gp-gc.adb:3
q.ads:8:04: undefined selector for type "NT" defined at line 6
gnatmake: "/home/matt/acl/impls/q.ads" compilation error

Compilation exited abnormally with code 2 at Mon Oct 26 03:53:30
(end of message)

This is unexpected, since I thought that children could see the
private components of types declared in the parent.

Does this have anything to do with the fact that the child is looking at
a type derived from the parent type, and not at the parent type
directly?

Is a view conversion to the parent type always required here?

This...
procedure GP.GC (O : in out NT) is
begin
   T (O).I := 1;
end;

...instead of
procedure GP.GC (O : in out NT) is
begin
   O.I := 1;
end;


Thanks,
Matt


generic
   type FT is private;
package GP is
   type T is tagged limited private;
private
   type T is
      tagged limited  record
        I : Integer;
      end record;
end GP;


generic
   type NT is new T with private;
procedure GP.GC (O : in out NT);


procedure GP.GC (O : in out NT) is
begin
   O.I := 1;
end;


with GP;
package P is new GP (Integer);


with P;
with GP.GC;
package Q is
   type NT is new P.T with null record;
   procedure C is new P.GC (NT);
end;


with Q;
procedure Test_Q is
begin
   null;
end;






             reply	other threads:[~1998-10-26  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-26  0:00 Matthew Heaney [this message]
1998-10-26  0:00 ` Visibility Rules For Children Martin Dowie
1998-10-27  0:00   ` Robert A Duff
1998-10-27  0:00     ` Martin Dowie
1998-10-27  0:00 ` Robert A Duff
1998-10-28  0:00 ` Stephen Leake
1998-10-29  0:00   ` Matthew Heaney
1998-11-02  0:00 ` Tucker Taft
replies disabled

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