From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: New aggregates with Ada 2022. Date: Mon, 20 Jun 2022 16:47:32 -0500 Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Mon, 20 Jun 2022 21:47:34 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="58ae5e8bcd39845de9e7a19af4c1f4e0"; logging-data="17167"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18M2Qsqw8avy8ExRVM4ee6jtdTc1C249sk=" Cancel-Lock: sha1:vywXNRTvqaH67bguZE0KVEUancs= X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 X-RFC2646: Format=Flowed; Response X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-Priority: 3 X-MSMail-Priority: Normal Xref: reader02.eternal-september.org comp.lang.ada:63999 List-Id: "Blady" wrote in message news:t8ml0l$1vo2$1@gioia.aioe.org... > Hello, > > Following the example section of RM Ada 2022 § 4.3.5 Container Aggregate, > I want to try map aggregates: > > 453. type Map_Type is private > 454. with Aggregate => (Empty => Empty_Map, > 455. Add_Named => Add_To_Map); > 456. > 457. procedure Add_To_Map (M : in out Map_Type; Key : in Integer; > Value : in String); > 458. > 459. Empty_Map : constant Map_Type; > ... -- End of example code > 482. private > ... > 488. type Map_Type is array (1..10) of String (1..10); This type is illegal, by 4.3.5(10/5): If the container type of an Aggregate aspect is a private type, the full type of the container type shall not be an array type. The reason for this is obvious in your question: it is ambiguous if an aggregate is an array aggregate or a container aggregate wherever the full type is visible, and that is not worth making work (any choice would be a surprise in some contexts). Apparently, GNAT failed to check for this error (probably because there aren't ACATS tests yet for Ada 2022, so errors of omission are very hard to find, not having a vetted set of tests). Secondly, early post Ada 2022 AIs have removed the possibility of using a constant for Empty_Map, since it does nto work with inheritance (and container aggregates are supposed to work with inheritance). So while GNAT may allow you to define Empty_Map this way now, it won't for very long. It will need to be a function. Randy.