comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: On absurdity of collections 7.6.1 (11.1/3)
Date: Wed, 29 Sep 2021 19:23:28 -0500	[thread overview]
Message-ID: <sj3020$u5$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: sj1i6g$7hv$1@gioia.aioe.org

It's surely wrong, because you have to deallocate from the same pool as you 
allocated. And you have no way to save such a thing. There is no capability 
in Ada to use multiple pools with one access type.

At best, you could directly call Allocate and Deallocate for this purpose, 
but it is impossible to use anything built-in.

You could use the subpool mechanism (assuming you want a limited number of 
kinds of pools) to do this (each subpool could use a different allocation 
mechanism). But that would mean a giant pool type containing all of the 
implementations -- which seems suboptimal. Note that the subpool mechanism 
ensures that finalization happens when a subpool is destroyed.

                      Randy.

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:sj1i6g$7hv$1@gioia.aioe.org...
> On 2021-09-29 13:05, Simon Wright wrote:
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>>
>>>        type Item_Ptr is access all Item;
>>>        function New_Item
>>>                 (  Pool : in out Root_Storage_Pool'Class;
>>>                    Text : String
>>>                 )  return Item_Ptr;
>>
>> What I don't see is how you can implement this, never mind any other
>> problems.
>
> A naive, but wrong due to 7.6.1 (11.1/3) nonsense, implementation would 
> be:
>
>      function New_Item
>               (  Pool : in out Root_Storage_Pool'Class;
>                  Text : String
>               )  return Item_Ptr is
>         type Ptr is access Item;
>         for Ptr'Storage_Pool use Pool;
>         Object : Ptr := new Item (Text'Length);
>      begin
>         Object.Text := Text;
>         return Object.all'Unchecked_Access;
>      end New_Item;
>
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de 


  parent reply	other threads:[~2021-09-30  0:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29  9:09 On absurdity of collections 7.6.1 (11.1/3) Dmitry A. Kazakov
2021-09-29 11:05 ` Simon Wright
2021-09-29 11:20   ` Dmitry A. Kazakov
2021-09-29 21:38     ` Simon Wright
2021-09-30  8:07       ` Dmitry A. Kazakov
2021-09-30  8:35         ` Simon Wright
2021-09-30  8:49           ` Dmitry A. Kazakov
2021-10-01  1:37         ` Randy Brukardt
2021-10-01  7:57           ` Dmitry A. Kazakov
2021-09-30  0:23     ` Randy Brukardt [this message]
2021-09-30  8:06       ` Dmitry A. Kazakov
2021-09-30 18:23 ` G.B.
2021-09-30 18:52   ` Dmitry A. Kazakov
2021-10-01  1:40     ` Randy Brukardt
2021-10-01  7:57       ` Dmitry A. Kazakov
replies disabled

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