* Ada.Containers.Indefinite_Holders and limited types
@ 2017-11-15 0:00 Victor Porton
2017-11-15 7:52 ` Simon Wright
2017-11-15 8:35 ` Dmitry A. Kazakov
0 siblings, 2 replies; 4+ messages in thread
From: Victor Porton @ 2017-11-15 0:00 UTC (permalink / raw)
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.
--
Victor Porton - http://portonvictor.org
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ada.Containers.Indefinite_Holders and limited types
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
1 sibling, 0 replies; 4+ messages in thread
From: Simon Wright @ 2017-11-15 7:52 UTC (permalink / raw)
Victor Porton <porton@narod.ru> writes:
> 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.
Because there are Holder operations that allow copying of the
Element_Type, perhaps; e.g. Copy.
Why not use "access Timing_Event'Class" or suchlike?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ada.Containers.Indefinite_Holders and limited types
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
1 sibling, 1 reply; 4+ messages in thread
From: Dmitry A. Kazakov @ 2017-11-15 8:35 UTC (permalink / raw)
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.
I prefer design with an external allocator, so I pass a access type to
my generic handles package.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Ada.Containers.Indefinite_Holders and limited types
2017-11-15 8:35 ` Dmitry A. Kazakov
@ 2017-11-15 22:24 ` Randy Brukardt
0 siblings, 0 replies; 4+ messages in thread
From: Randy Brukardt @ 2017-11-15 22:24 UTC (permalink / raw)
"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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-11-15 22:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox