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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Indefinite Containers of Indefinite Private Types Date: Tue, 04 Aug 2015 08:40:36 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net WFJ5atf0XYWDTSDT9qTnbwOG9F03ZnAzNHMpeTT6KD1z2R1j26 Cancel-Lock: sha1:FredcF+w8ZhuqsTHFDR/XeCz1ks= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:27350 Date: 2015-08-04T08:40:36+03:00 List-Id: 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 . @ .