comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: New aggregates with Ada 2022.
Date: Mon, 20 Jun 2022 16:47:32 -0500	[thread overview]
Message-ID: <t8qptm$gof$2@dont-email.me> (raw)
In-Reply-To: t8ml0l$1vo2$1@gioia.aioe.org

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]

"Blady" <p.p11@orange.fr> 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.


  parent reply	other threads:[~2022-06-20 21:47 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-19  7:59 New aggregates with Ada 2022 Blady
2022-06-19 14:15 ` Simon Wright
2022-06-20 19:36   ` Blady
2022-06-20 22:01     ` Simon Wright
2022-06-20 21:47 ` Randy Brukardt [this message]
2022-06-20 22:18   ` Dmitry A. Kazakov
2022-06-21 23:28     ` Randy Brukardt
2022-06-22  9:04       ` Dmitry A. Kazakov
2022-06-23  1:06         ` Randy Brukardt
2022-06-23  9:32           ` Dmitry A. Kazakov
2022-06-23 10:53             ` G.B.
2022-06-24  1:21               ` Randy Brukardt
2022-06-24  1:24             ` Randy Brukardt
2022-06-24  6:50               ` Dmitry A. Kazakov
2022-06-25  3:13                 ` Randy Brukardt
2022-06-25  8:50                   ` Dmitry A. Kazakov
2022-06-27 21:37                     ` Randy Brukardt
2022-06-28  5:36                       ` Niklas Holsti
2022-06-29  4:01                         ` Randy Brukardt
2022-06-29  8:30                           ` Jeffrey R.Carter
2022-06-29  9:04                             ` Dmitry A. Kazakov
2022-06-30  5:03                               ` Randy Brukardt
2022-06-30  8:44                                 ` Dmitry A. Kazakov
2022-06-29 11:06                             ` Niklas Holsti
2022-06-29 12:53                               ` Jeffrey R.Carter
2022-06-30  5:07                                 ` Randy Brukardt
2022-06-30  5:14                               ` Randy Brukardt
2022-06-30  8:31                                 ` Marius Amado-Alves
2022-07-01  5:20                                   ` Randy Brukardt
2022-06-30 10:30                                 ` Jeffrey R.Carter
2022-06-30 15:48                                   ` Marius Amado-Alves
2022-06-30 16:39                                     ` Jeffrey R.Carter
2022-07-01  0:07                                       ` Marius Amado-Alves
2022-06-28  7:52                       ` Dmitry A. Kazakov
2022-06-29  4:07                         ` Randy Brukardt
2022-06-29  7:24                           ` Dmitry A. Kazakov
2022-06-30  5:00                             ` Randy Brukardt
2022-06-21 23:39     ` Randy Brukardt
2022-06-22  8:26       ` Dmitry A. Kazakov
2022-06-23  1:10         ` Randy Brukardt
2022-06-23  9:32           ` Dmitry A. Kazakov
2022-06-20 22:10 ` Jesper Quorning
2022-06-20 22:59   ` Jesper Quorning
2022-06-21 23:20     ` Randy Brukardt
replies disabled

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