comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Is this actually possible?
Date: Wed, 11 Dec 2019 20:00:58 -0600
Date: 2019-12-11T20:00:58-06:00	[thread overview]
Message-ID: <qss70r$n88$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: qsrncj$u95$1@gioia.aioe.org

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:qsrncj$u95$1@gioia.aioe.org...
> On 2019-12-11 22:12, Lucretia wrote:
...
> Why? You must know all variants in order to compute the array element 
> size. In Ada you cannot have it either:
>
>    type Not_an_Array is array (Positive range <>) of T'Class;
>
> This is illegal.

This is the purpose of the Bounded_Indefinite_Holders, because this is a 
useful thing to do sometimes.

    package My_Holders is new Ada.Containers.Bounded_Indefinite_Holders 
(T'Class, 100);

    type An_Array is array (Positive range <>) of My_Holders.Holder;

Here, a Holder will hold up to 100 storage units. If some extension of 
T'Class is bigger than that, setting the holder to a value of that extension 
raises Program_Error. (As with most checks, this one can be suppressed, and 
if it would fail and is suppressed, the program is erroneous - presumably 
some other object memory would be overwritten. So don't do that. ;-)

This is probably one of the best (and simplest) ideas of Ada 202x. Thanks to 
Niklas Holsti for the original idea (although I think the actual resulting 
package isn't much like Niklas' original idea).

                         Randy.





  reply	other threads:[~2019-12-12  2:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-11 16:43 Is this actually possible? Lucretia
2019-12-11 17:38 ` Dmitry A. Kazakov
2019-12-11 17:54   ` Lucretia
2019-12-11 19:55     ` Randy Brukardt
2019-12-11 19:58     ` Dmitry A. Kazakov
2019-12-11 21:12       ` Lucretia
2019-12-11 21:34         ` Dmitry A. Kazakov
2019-12-12  2:00           ` Randy Brukardt [this message]
2019-12-12  9:26             ` Niklas Holsti
2020-04-08 16:10             ` Alejandro R. Mosteo
2019-12-12 10:17           ` Lucretia
2019-12-12 14:32             ` Dmitry A. Kazakov
2019-12-12 15:14               ` Lucretia
2019-12-12 15:15                 ` Lucretia
2019-12-12 18:24                   ` Dmitry A. Kazakov
2019-12-12 18:30                     ` Lucretia
2019-12-12 19:09                       ` Dmitry A. Kazakov
2019-12-12 20:54                         ` Lucretia
2019-12-12 21:12                           ` Dmitry A. Kazakov
2019-12-13 11:11                             ` Lucretia
2019-12-11 19:59 ` 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