comp.lang.ada
 help / color / mirror / Atom feed
From: Natasha Kerensikova <lithiumcat@gmail.com>
Subject: Re: How to declare a generic formal type "covered" by another?
Date: Thu, 1 May 2014 17:56:21 +0000 (UTC)
Date: 2014-05-01T17:56:21+00:00	[thread overview]
Message-ID: <slrnlm52m4.i0l.lithiumcat@nat.rebma.instinctive.eu> (raw)
In-Reply-To: ljtiiq$ukp$1@dont-email.me

On 2014-05-01, J-P. Rosen <rosen@adalog.fr> 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

  reply	other threads:[~2014-05-01 17:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
replies disabled

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