comp.lang.ada
 help / color / mirror / Atom feed
From: "Alejandro R. Mosteo" <alejandro@mosteo.com>
Subject: Re: Is this actually possible?
Date: Wed, 8 Apr 2020 18:10:39 +0200
Date: 2020-04-08T18:10:39+02:00	[thread overview]
Message-ID: <r6kt20$uef$1@dont-email.me> (raw)
In-Reply-To: <qss70r$n88$1@franka.jacob-sparre.dk>

I apologize for unearthing this old topic; I just came around to it.

On 12/12/19 3:00, Randy Brukardt wrote:

> 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).

I tried to use the GNAT CE 2019 Bounded_Holders once and got bitten by 
them being implemented with casts/address wizardry. This meant that 
storing controlled types and copying them while in bounded disguise 
broke finalization internals. (I don't remember the specifics, sorry).

Is this an implementation allowance? I see note 13/5 at 
http://www.ada-auth.org/standards/2xrm/html/RM-A-18-32.html#I8180 that 
implies that Finalization should work.

But then I also realize that the ARM package name is 
Bounded_Indefinite_Holders and not Bounded_Holders, so maybe the version 
I used is an early implementation.

(This is what I have: 
https://github.com/gcc-mirror/gcc/blob/master/gcc/ada/libgnat/a-coboho.ads)

  parent reply	other threads:[~2020-04-08 16:10 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
2019-12-12  9:26             ` Niklas Holsti
2020-04-08 16:10             ` Alejandro R. Mosteo [this message]
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