From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Indefinite Containers of Indefinite Private Types
Date: Tue, 04 Aug 2015 08:40:36 +0300
Date: 2015-08-04T08:40:36+03:00 [thread overview]
Message-ID: <d2b1ikF39bvU1@mid.individual.net> (raw)
In-Reply-To: <mpp7js$kac$2@dont-email.me>
On 15-08-04 05:23 , Jeffrey R. Carter wrote:
> This is legal:
>
> package Indefinite1 is
> type T (<>) is private;
> private -- Indefinite1
> type T is new String;
> end Indefinite1;
>
> with Indefinite1;
> with Ada.Containers.Indefinite_Vectors;
>
> package Indefinite2 is
> use type Indefinite1.T;
>
> package Lists is new Ada.Containers.Indefinite_Vectors
> (Index_Type => Positive, Element_Type => Indefinite1.T);
> end Indefinite2;
>
> But this isn't:
>
> with Ada.Containers.Indefinite_Vectors;
>
> package Indefinite1 is
> type T (<>) is private;
> private -- Indefinite1
> package Lists is new Ada.Containers.Indefinite_Vectors
> (Index_Type => Positive, Element_Type => T);
>
> type T is new String;
> end Indefinite1;
>
> It seems to me that both instantiations have all the information they need.
> Probably I'm missing something, but why is the latter illegal?
I'm not sure that I have understood your question correctly -- are you
asking for the RM rule that makes this illegal, or for the reason behind
that rule?
At the point of instantiation in the second case, "T" is a partial view
of the type. RM 7.3(5) says "... Similarly, before the full declaration,
the name of the partial view cannot be used in a generic_instantiation
or in a representation item."
As to why this rule exists, I suspect it has to do with the "rechecks"
discussed in the annotated RM 12.3(11) where the legality of an
instantiation is checked by comparing the actual types with the _full_
declaration of the generic (not only with the declarations of the
generic formals). It might be difficult to apply these rechecks if the
actual type is only a partial view.
The second case becomes legal if the full declaration of type T is moved
to occur before the instantiation -- as happens in the first case -- but
you probably knew that.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2015-08-04 5:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 2:23 Indefinite Containers of Indefinite Private Types Jeffrey R. Carter
2015-08-04 5:40 ` Niklas Holsti [this message]
2015-08-04 18:56 ` Jeffrey R. Carter
2015-08-04 20:47 ` Randy Brukardt
2015-08-04 20:56 ` Jeffrey R. Carter
2015-08-06 18:49 ` Randy Brukardt
2015-08-06 20:12 ` Jeffrey R. Carter
2015-08-07 19:49 ` Randy Brukardt
2015-08-07 20:13 ` Bob Duff
2015-08-07 20:45 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox