From: sbelmont700@gmail.com
Subject: Generic Parent Specification
Date: Tue, 11 Feb 2020 03:15:07 -0800 (PST)
Date: 2020-02-11T03:15:07-08:00 [thread overview]
Message-ID: <7b1e3204-6a95-4d33-a967-a458566208f2@googlegroups.com> (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
next reply other threads:[~2020-02-11 11:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 11:15 sbelmont700 [this message]
2020-02-11 12:33 ` Generic Parent Specification Egil H H
2020-02-12 10:24 ` sbelmont700
2020-02-12 19:25 ` AdaMagica
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox