From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: How to declare a generic formal type "covered" by another? Date: Thu, 1 May 2014 06:54:29 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: Injection-Date: Thu, 1 May 2014 06:54:29 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="76a49b86bc3e16725b7cfca3d85cb4c8"; logging-data="19030"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Vmr9iicC5XnXqyYu1tjmg" User-Agent: slrn/1.0.1 (FreeBSD) Cancel-Lock: sha1:LbofiEQu82i5Ljti+WZZLQXspDU= X-Original-Bytes: 2517 Xref: number.nntp.dca.giganews.com comp.lang.ada:186178 Date: 2014-05-01T06:54:29+00:00 List-Id: 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