* generic child package
@ 2006-07-23 6:44 nblanpain
2006-07-23 7:24 ` Dmitry A. Kazakov
0 siblings, 1 reply; 5+ messages in thread
From: nblanpain @ 2006-07-23 6:44 UTC (permalink / raw)
Is my example correct ? :
------------------------------
generic
with type T_Toto is private;
package Parent is
pragma Pure;
end Parent;
------------------------------
------------------------------
generic
package Parent.Child1 is
type T_Child1 is tagged private;
....
end Parent.Child1;
------------------------------
------------------------------
generic
with P_Child1 is new Parent.Child1; ----- or with P_Child1 is new
Parent.Child1 (<>); ?????
package Parent.Child2 is
type T_Child2 is new P_Child1.T_Child1 with private;
....
end Parent.Child2;
------------------------------
Is there or problem or is it correct ?
Thanks,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: generic child package
2006-07-23 6:44 generic child package nblanpain
@ 2006-07-23 7:24 ` Dmitry A. Kazakov
2006-07-23 17:57 ` nblanpain
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry A. Kazakov @ 2006-07-23 7:24 UTC (permalink / raw)
On 22 Jul 2006 23:44:58 -0700, nblanpain@hotmail.com wrote:
> Is my example correct ? :
>
> ------------------------------
> generic
> with type T_Toto is private;
type T_Toto is private;
> package Parent is
> pragma Pure;
> end Parent;
> ------------------------------
>
> ------------------------------
> generic
> package Parent.Child1 is
> type T_Child1 is tagged private;
> ....
> end Parent.Child1;
> ------------------------------
>
> ------------------------------
> generic
> with P_Child1 is new Parent.Child1; ----- or with P_Child1 is new
> Parent.Child1 (<>); ?????
with package P_Child1 is new Parent.Child1;
> package Parent.Child2 is
> type T_Child2 is new P_Child1.T_Child1 with private;
> ....
> end Parent.Child2;
> ------------------------------
>
> Is there or problem or is it correct ?
What about:
generic
package Parent.Child1.Grandchild1 is
type T_Grandchild1 is new T_Child1 with private;
....
end Parent.Child1.Grandchild1;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: generic child package
2006-07-23 7:24 ` Dmitry A. Kazakov
@ 2006-07-23 17:57 ` nblanpain
2006-07-23 18:08 ` Ludovic Brenta
2006-07-24 7:26 ` Dmitry A. Kazakov
0 siblings, 2 replies; 5+ messages in thread
From: nblanpain @ 2006-07-23 17:57 UTC (permalink / raw)
yes excuse me :
generic
type T_Toto is private;
but are you sur it is :
with P_Child1 is new Parent.Child1;
and not
with P_Child1 is new Parent.Child1 (<>);
thanks,
Dmitry A. Kazakov a écrit :
> On 22 Jul 2006 23:44:58 -0700, nblanpain@hotmail.com wrote:
>
> > Is my example correct ? :
> >
> > ------------------------------
> > generic
> > with type T_Toto is private;
>
> type T_Toto is private;
>
> > package Parent is
> > pragma Pure;
> > end Parent;
> > ------------------------------
> >
> > ------------------------------
> > generic
> > package Parent.Child1 is
> > type T_Child1 is tagged private;
> > ....
> > end Parent.Child1;
> > ------------------------------
> >
> > ------------------------------
> > generic
> > with P_Child1 is new Parent.Child1; ----- or with P_Child1 is new
> > Parent.Child1 (<>); ?????
>
> with package P_Child1 is new Parent.Child1;
>
> > package Parent.Child2 is
> > type T_Child2 is new P_Child1.T_Child1 with private;
> > ....
> > end Parent.Child2;
> > ------------------------------
> >
> > Is there or problem or is it correct ?
>
> What about:
>
> generic
> package Parent.Child1.Grandchild1 is
> type T_Grandchild1 is new T_Child1 with private;
> ....
> end Parent.Child1.Grandchild1;
>
> --
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: generic child package
2006-07-23 17:57 ` nblanpain
@ 2006-07-23 18:08 ` Ludovic Brenta
2006-07-24 7:26 ` Dmitry A. Kazakov
1 sibling, 0 replies; 5+ messages in thread
From: Ludovic Brenta @ 2006-07-23 18:08 UTC (permalink / raw)
nblanpain@hotmail.com writes:
> yes excuse me :
>
> generic
> type T_Toto is private;
>
> but are you sur it is :
> with P_Child1 is new Parent.Child1;
Yes, that's correct. Have you looked at the Wikibook chapter on
generics? It is here:
http://en.wikibooks.org/wiki/Ada_Programming/Generics
> and not
> with P_Child1 is new Parent.Child1 (<>);
--
Ludovic Brenta.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: generic child package
2006-07-23 17:57 ` nblanpain
2006-07-23 18:08 ` Ludovic Brenta
@ 2006-07-24 7:26 ` Dmitry A. Kazakov
1 sibling, 0 replies; 5+ messages in thread
From: Dmitry A. Kazakov @ 2006-07-24 7:26 UTC (permalink / raw)
On 23 Jul 2006 10:57:06 -0700, nblanpain@hotmail.com wrote:
> yes excuse me :
>
> generic
> type T_Toto is private;
>
> but are you sur it is :
> with P_Child1 is new Parent.Child1;
> and not
> with P_Child1 is new Parent.Child1 (<>);
Side comment. Both are wrong. It must be "with package <formal-name> is
..".
The box (<>) indicates that the parameters of a package instance could be
any. Parent.Child1 does not have parameters of its own, so no box.
In (rare) case you wished to pass P_Child1, child of a *different* instance
of Parent, you would pass its Parent as well:
with Parent.Child1;
generic
with package P is new Parent (<>);
-- Parent has parameters, we don't care which, so the box
with package P_Child1 is new P.Child1;
-- Note, how P_Child1 refers to P, an instance of Parent potentially
-- different from the parent of Child2
package Parent.Child2 is
type T_Child2 is new P_Child1.T_Child1 with null record;
end Parent.Child2;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-07-24 7:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-23 6:44 generic child package nblanpain
2006-07-23 7:24 ` Dmitry A. Kazakov
2006-07-23 17:57 ` nblanpain
2006-07-23 18:08 ` Ludovic Brenta
2006-07-24 7:26 ` Dmitry A. Kazakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox