comp.lang.ada
 help / color / mirror / Atom feed
* Specialization generic package parameters
@ 2008-05-23 17:29 Dmitry A. Kazakov
  2008-05-23 20:17 ` christoph.grein
  2008-05-24 12:48 ` Stephen Leake
  0 siblings, 2 replies; 5+ messages in thread
From: Dmitry A. Kazakov @ 2008-05-23 17:29 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-05-24 14:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-23 17:29 Specialization generic package parameters Dmitry A. Kazakov
2008-05-23 20:17 ` christoph.grein
2008-05-24  8:00   ` Dmitry A. Kazakov
2008-05-24 12:48 ` Stephen Leake
2008-05-24 14:07   ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox