comp.lang.ada
 help / color / mirror / Atom feed
* 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

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