From: Andrea Taverna <a.tavs@hotmail.it>
Subject: Re: Visibility of package parameters in child packages
Date: Wed, 16 Dec 2009 03:50:12 -0800 (PST)
Date: 2009-12-16T03:50:12-08:00 [thread overview]
Message-ID: <02e4d172-0eb9-4c2a-ac0f-68e151916d59@o19g2000vbj.googlegroups.com> (raw)
In-Reply-To: 4b27f8e9$0$6591$9b4e6d93@newsspool3.arcor-online.net
On 15 Dic, 22:00, Georg Bauhaus <rm.dash-bauh...@futureapps.de> wrote:
> Andrea Taverna schrieb:
>
>
>
> > generic
> > with package P is new Q (<>);
> > use P;
> > package Parent is
> > ...
> > end Parent;
>
> > generic
> > Parent.Child is
> > ...
> > end Parent.Child;
>
> > I can see P declarations inside Parent, but in Child I need to prefix
> > everything with 'P.', even if I add a use-clause.
> > This happens with gnat-4.3.0 .
> > Is it normal? How can I "use" P inside Child?
>
> generic
> Parent.Child is
> use P;
> end Parent.Child;
I compiled the following
-----%<-----%<-----%<-----%<-----%<
-- SIGNATURE PACKAGE
generic
type T is private;
with function F(X : T) return T;
package Q is end Q;
-- PARENT
with Q;
with Ada.Text_IO;
generic
with package P is new Q(<>);
use P;
package Parent is
procedure A (X : T);
end Parent;
package body Parent is
procedure A (X : T) is
C : T := F(X);
begin
Ada.Text_IO("Hello");
end A;
end Parent;
-- CHILD
generic
package Parent.Child is
use P;
function B(X : T) return T;
end Parent.Child;
package body Parent.Child is
function B(X : T) return T is
use P;
D : T := F(X);
begin
return F(D);
end B;
end Parent.Child;
-- INSTANTIATION
with Parent.Child;
with Q;
procedure Main is
function Incf(X : Integer) return Integer is begin return X + 1;
end Incf;
package R is new Q(Integer, Incf);
package Par is new Parent(R);
package Ch is new Par.Child;
begin
null;
end Main;
-----%<-----%<-----%<-----%<-----%<
and the compiler replied
-----%<-----%<-----%<-----%<-----%<
]# gnatmake main.adb
gcc -c main.adb
main.adb:9:05: instantiation error at parent-child.adb:6
main.adb:9:05: "F" is not visible (more references follow)
main.adb:9:05: instantiation error at parent-child.adb:6
main.adb:9:05: non-visible declaration at q.ads:3
gnatmake: "main.adb" compilation error
-----%<-----%<-----%<-----%<-----%<
Am I missing something?
next prev parent reply other threads:[~2009-12-16 11:50 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-15 19:28 Visibility of package parameters in child packages Andrea Taverna
2009-12-15 21:00 ` Georg Bauhaus
2009-12-16 11:50 ` Andrea Taverna [this message]
2009-12-16 13:14 ` Georg Bauhaus
2009-12-16 14:21 ` Andrea Taverna
2009-12-16 15:54 ` Georg Bauhaus
2009-12-16 16:54 ` Andrea Taverna
2009-12-16 18:54 ` Georg Bauhaus
2009-12-16 21:44 ` Adam Beneschan
2009-12-16 21:26 ` sjw
2009-12-17 0:19 ` Randy Brukardt
2009-12-17 18:50 ` Ludovic Brenta
2009-12-16 21:27 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox