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!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Indefinite Containers of Indefinite Private Types Date: Fri, 7 Aug 2015 13:45:24 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <87a8u2luvy.fsf@theworld.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Fri, 7 Aug 2015 20:43:49 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="ee44d3db9c41f5ad88d7e8e8f0268f05"; logging-data="9887"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/iCEmD/wzJZZyZqLN29lWeqkZwKjmQA9s=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 In-Reply-To: <87a8u2luvy.fsf@theworld.com> Cancel-Lock: sha1:QnXLNg1Uv24irtOXQOIHY4guNz8= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:27390 Date: 2015-08-07T13:45:24-07:00 List-Id: On 08/07/2015 01:13 PM, Bob Duff wrote: > "Jeffrey R. Carter" writes: > >> Yes, of course. The examples are simplified from a more complex case where the >> container is used in the full type definition. This can be achieved by adding >> some additional code that is essentially noise, or by using access types. >> Avoiding access types is worth adding noise, but it would be nice if the noise >> were unnecessary. > > I'm curious what the "noise" looks like in your case. > > Last time I ran into this problem I think I ended up using a workaround > that involved access types. I don't remember the details. It involves using tagged types, type extension, and a container of a class-wide type: with Ada.Containers.Indefinite_Vectors; package P is type T (<>) is private; private type Root is tagged null record; package Lists is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Root'Class); type T is new Root with record List : Lists.Vector; end T; end P; The only reason for the type extension is to get the instantiation that can be used in the full declaration of T. The only objects that will be stored in a vector are of type T. In addition to the noise of the Root type and the extension for T, there are type conversions required that are part of the noise. -- Jeff Carter "From this day on, the official language of San Marcos will be Swedish." Bananas 28