* Generic Parent Specification
@ 2020-02-11 11:15 sbelmont700
2020-02-11 12:33 ` Egil H H
2020-02-12 19:25 ` AdaMagica
0 siblings, 2 replies; 4+ messages in thread
From: sbelmont700 @ 2020-02-11 11:15 UTC (permalink / raw)
Is there any incantation for generics that allows you to specify that one actual generic package must be a child of another? Suppose a generic package along with a child, and then a third generic that withs in them both, e.g:
generic
package X is
type T1 is new Integer;
end X;
generic
package X.Y is
subtype T2 is T1;
end X.Y;
generic
with package K1 is new X (<>);
with package K2 is new X.Y (<>);
package P is
o1 : K2.T2 := 0;
o2 : K1.T1 := o1; -- error!
end P;
The error seems sensible enough, since the actual for K1 might not actually be a "real" parent of the actual for K2, and the types might indeed be incompatible. But in cases where K2 is a legit child of K1, the conversion ought to be fine. Conceptually I want something like this:
generic
with package K1 is new X (<>);
with package K2 is new K1.Y (<>); -- K2 must be a instantiation of X.Y from K1
but either I can't find the right spell to do this, or it's not possible. Any ideas?
-sb
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Generic Parent Specification
2020-02-11 11:15 Generic Parent Specification sbelmont700
@ 2020-02-11 12:33 ` Egil H H
2020-02-12 10:24 ` sbelmont700
2020-02-12 19:25 ` AdaMagica
1 sibling, 1 reply; 4+ messages in thread
From: Egil H H @ 2020-02-11 12:33 UTC (permalink / raw)
On Tuesday, February 11, 2020 at 12:15:08 PM UTC+1, sbelm...@gmail.com wrote:
>
> generic
> with package K1 is new X (<>);
> with package K2 is new K1.Y (<>); -- K2 must be a instantiation of X.Y from K1
>
> but either I can't find the right spell to do this, or it's not possible. Any ideas?
>
> -sb
Works for me...
Which compiler/version are you using? What is the exact error message?
--
~egilhh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Generic Parent Specification
2020-02-11 12:33 ` Egil H H
@ 2020-02-12 10:24 ` sbelmont700
0 siblings, 0 replies; 4+ messages in thread
From: sbelmont700 @ 2020-02-12 10:24 UTC (permalink / raw)
On Tuesday, February 11, 2020 at 7:33:15 AM UTC-5, Egil H H wrote:
> On Tuesday, February 11, 2020 at 12:15:08 PM UTC+1, sbelm...@gmail.com wrote:
> >
> > generic
> > with package K1 is new X (<>);
> > with package K2 is new K1.Y (<>); -- K2 must be a instantiation of X.Y from K1
> >
> > but either I can't find the right spell to do this, or it's not possible. Any ideas?
> >
> > -sb
>
> Works for me...
> Which compiler/version are you using? What is the exact error message?
>
> --
> ~egilhh
It does appear to be a compiler bug; this syntax works in other versions. Thank you very much for your response.
-sb
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Generic Parent Specification
2020-02-11 11:15 Generic Parent Specification sbelmont700
2020-02-11 12:33 ` Egil H H
@ 2020-02-12 19:25 ` AdaMagica
1 sibling, 0 replies; 4+ messages in thread
From: AdaMagica @ 2020-02-12 19:25 UTC (permalink / raw)
You missed the with clause:
with X.Y;
generic
with package K1 is new X (<>);
with package K2 is new K1.Y (<>);
package P is
o1 : K2.T2 := 0;
o2 : K1.T1 := o1;
end P;
Note the name X.Y in the with clause and K1.Y in the instantiation.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-02-12 19:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-11 11:15 Generic Parent Specification sbelmont700
2020-02-11 12:33 ` Egil H H
2020-02-12 10:24 ` sbelmont700
2020-02-12 19:25 ` AdaMagica
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox