comp.lang.ada
 help / color / mirror / Atom feed
* How to declare a generic formal type "covered" by another?
@ 2014-05-01  6:54 Natasha Kerensikova
  2014-05-01  7:09 ` J-P. Rosen
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Natasha Kerensikova @ 2014-05-01  6:54 UTC (permalink / raw)


Hello,

this a general question stemmed by a new idea on how to solve the
problem exposed in my previous thread (I wouldn't have started a new
thread if I knew my newsreader well enough to do so).

I'm not good enough with language-lawyer vocabulary (hence the quotes
around "covered" in the subject), so I'll write it mostly in Ada.
Basically I want two generic formal T and S, so that I can write:

   Access_To_T_Value := new S;

I too the verb "cover" from 4.8(3/1) to mean this relationship between S
and T, but I'm not sure how correct it is.

The context would look like that:

   generic
      type T (<>) is limited private;
   package References is

      type Exposed_Type is tagged private;

      generic
         type S is adequately declared;
      function Allocate return Exposed_Type;

   private
      type Internal_Access is access T;
      type Exposed_Type is new Ada.Finalization.Controlled with record
         Value : Internal_Access;
      end record;
   end References;

   package body References is
      function Allocate return Exposed_Type is
      begin
         return (Ada.Finalization.Controlled with
            Value => new S);
      end Allocate;
   end References;


So S would have to be a concrete constrained type, but looking at the
alternatives for "formal_type_definition", I can't see anything that
covers both S being a constrained version of T, and S being a concrete
tagged type belonging to class-wide T.

Is it possible, or am I hitting a limit of Ada generics?



Thanks for your help,
Natasha


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

end of thread, other threads:[~2014-05-02 16:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-01  6:54 How to declare a generic formal type "covered" by another? Natasha Kerensikova
2014-05-01  7:09 ` J-P. Rosen
2014-05-01  7:33   ` Natasha Kerensikova
2014-05-01 13:35     ` J-P. Rosen
2014-05-01 17:56       ` Natasha Kerensikova
2014-05-01 20:59     ` Jeffrey Carter
2014-05-02  7:58       ` AdaMagica
2014-05-02  8:17         ` Natasha Kerensikova
2014-05-02 15:12         ` Jeffrey Carter
2014-05-02 15:33           ` Dmitry A. Kazakov
2014-05-02 16:00           ` AdaMagica
2014-05-01  9:30 ` Georg Bauhaus
2014-05-01  9:32 ` Georg Bauhaus
2014-05-01  9:33 ` Georg Bauhaus
2014-05-01 16:34 ` Georg Bauhaus
2014-05-01 18:11   ` Natasha Kerensikova

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