From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Ada.Containers.Indefinite_Holders and limited types
Date: Wed, 15 Nov 2017 16:24:52 -0600
Date: 2017-11-15T16:24:52-06:00 [thread overview]
Message-ID: <ouierk$gj1$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: ougu7j$1g1c$1@gioia.aioe.org
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:ougu7j$1g1c$1@gioia.aioe.org...
> On 15/11/2017 01:00, Victor Porton wrote:
>> Why Ada.Containers.Indefinite_Holders (as of Ada2012) accepts "private"
>> Element_Type? I would like it be "limited private" instead.
>>
>> The particular reason I want this is to hold Timing_Event inside an
>> indefinite holder inside a record.
>
> It is a design choice. Handles can use either external or internal
> allocator. The latter option requires copying, so it cannot be limited,
> the former option might be less comfortable.
Right. The Insert operation of all of the containers requires making a new
copy of the element in the container. That's necessary if one wants the
container to handle all of the storage management for the elements (which
was an explicit design goal of the containers -- preventing the need to use
explicit access types for non-limited element types).
> I prefer design with an external allocator, so I pass a access type to my
> generic handles package.
That's a fine alternative; it does put the storage management burden on the
client (which we were trying to avoid). Note that you can use the definite
containers to do this - which is another reason to use non-limited element
types.
Several of us have tried to design containers that could directly contain
limited objects, but no one (me included) has been able to come up with
anything that had any significant advantage over just putting an explicit
general access value into the container instead (and getting that value from
'Access of an aliased object).
Randy.
prev parent reply other threads:[~2017-11-15 22:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-15 0:00 Ada.Containers.Indefinite_Holders and limited types Victor Porton
2017-11-15 7:52 ` Simon Wright
2017-11-15 8:35 ` Dmitry A. Kazakov
2017-11-15 22:24 ` Randy Brukardt [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox