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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: Re: How to declare a generic formal type "covered" by another? Date: Thu, 1 May 2014 17:56:21 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 1 May 2014 17:56:21 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="76a49b86bc3e16725b7cfca3d85cb4c8"; logging-data="17689"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WXxGTPM8uUDCwdjBna7qb" User-Agent: slrn/1.0.1 (FreeBSD) Cancel-Lock: sha1:2TF8oNr8Jf2JKpYBbRAzQZLwlIg= Xref: news.eternal-september.org comp.lang.ada:19637 Date: 2014-05-01T17:56:21+00:00 List-Id: On 2014-05-01, J-P. Rosen wrote: > Le 01/05/2014 09:33, Natasha Kerensikova a écrit : >> The examples I had in mind are: >> - T is Stream_Element_Array, S is Stream_Element_Array (1 .. 4096) > This is an unconstrained type and a constrained subtype of it. > >> - T is Root_Stream_Type'Class, S is a concrete type derived from it > This is an indefinite type, and a definite type derived from it. So it seems they are indeed deeply different. Is there really no way to describe both situations with the same words? If I understand correctly your answer below, in both cases T is indefinite while S is definite, right? Also if infer correctly the vocabulary from 4.8(3/3), in both cases T covers S, right? If both are right, then the correct wording for my initial question would be "How to declare a generic formal definite type covered by a given format indefinite type?" >>> 3) There is no way to say that S must be constrained, because being >>> constrained is a matter of subtype, and only types matter for generics. >> >> Well maybe the problem here is my limited vocabulary. I used the word >> "constrained" there only to mean "Something := new S" or "Variable : S;" >> are both valid, i.e. objects of that type can be created without >> further information. > This is definite vs. indefinite types. OK, thanks >> There must be some way to express that in generics. > An unknown discriminant in a formal, i.e. "(<>)", expresses that the > type may be indefinite. > > Now, thinking about it... When you derive a formal from an indefinite > type, it stays indefinite. OTOH, you can derive from a definite type and > give unknown discriminants to make indefinite. Add to that that a type > is considered derived from itself, and the following compiles OK: > > procedure Essai is > [...] > end Essai; > > Close enough to what you wanted? Unfortunately not, since I need the covering indefinite type on a shallower accessibility level than the covered definite type, since the latter is only used to create reference to the former and those references are used everywhere else. Thanks for your help, Natasha