Is it possible to access child package declarations from a parent package ?
-- parent.ads
package Parent is
procedure F(A : Child_Type);
end Parent;
-- parent-child.ads
package Parent.Child is
type Child_Type is (A, B, C);
end Parent.Child;
The nested version works fine :
-- parent.ads
package Parent is
package Child is
type Child_Type is (A, B, C);
end Child;
use Child;
procedure F(A : Child_Type);
end Parent;
And maybe there is another way to do this since I think it is not possible using child packages...
In general, no; the second example works because the specification of Child
is known when F
is declared in Parent
. In light of your previous question on this topic, it may be that you want a clean way to separate multiple implementations of a common specification. This related Q&A discusses two approaches: one using inheritance and the other using a library-based mechanism at compile-time.