Recently I ran into the following problem with generic packages. Consider
type T is tagged null record;
and a generic package that uses it:
generic
type Some_T is new T with private;
package P is
...
private
...
end P;
Let there be some type S derived from T:
type S is new T with null record;
Now the question is, how to derive another package Q from P, specialized
for S, while keeping access to the private part of P?
Neither of patterns I know works.
1. Nested package:
generic
type Some_S is new S with private;
package Q is
package P_S is new P (Some_S); -- This specializes P
private
-- No access to the private part of P!
end Q;
2. Formal package:
generic
type Some_S is new S with private;
package P_S is new P (Some_S); -- This specializes P
package Q is
...
private
-- No access to the private part of P!
end Q;
3. Child package
generic
package P.Q is
private
-- Got access to the private part, but
-- lost specialization, as the parameter
-- of P is no more constrained to S.
end P;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de