From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada containers and custom allocators
Date: Wed, 9 Jan 2008 18:09:45 +0100
Date: 2008-01-09T18:09:49+01:00 [thread overview]
Message-ID: <15hfjzq5cr38z.8ffcg9kk0ibm.dlg@40tude.net> (raw)
In-Reply-To: wcchchnc905.fsf@shell01.TheWorld.com
On Wed, 09 Jan 2008 10:29:46 -0500, Robert A Duff wrote:
> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
>
>> On Tue, 8 Jan 2008 17:54:44 -0600, Randy Brukardt wrote:
>>
>>> But it isn't valuable enough to force every user
>>> of a container to define a storage pool (since there is no name for a
>>> standard storage pool).
>>
>> That always wondered me, why there is no name for. Especially because the
>> default storage pool can be obtained anyway:
>>
>> type Some_Ptr is access Integer; -- Goes to the default storage pool
>> package Foo is new Boo (Some_Ptr'Storage_Pool);
>
> The compiler is not required to use the same storage pool for all
> types. Therefore, the concept "THE default pool" does not exist.
>
> Some_Ptr'Storage_Pool might be a special pool tuned for the fact that
> Size_In_Storage_Elements = 4 and Alignment = 4. Allocate could
> add 4 to a known-aligned pointer, and ignore the
> Size_In_Storage_Elements and Alignment parameters.
>
> If Boo uses this pool for something other than Integer,
> it might not work.
Which is broken then. Because it does not fulfill the contract of
Storage_Pool'Class. I guess that Allocate is allowed to raise
Storage_Error, but not to ignore parameters.
If the implementation handles a family of pools one per object's size power
of two or like that, then it should return the family root rather than the
size-specific pool. Otherwise, the following will work either:
type Integer_Ptr is access Integer;
type Character_Ptr is access Character;
for Character_Ptr'Storage_Pool use Integer_Ptr'Storage_Pool;
I think ARM should clarify the issue of how pools could be constrained
while allowing a safe use.
> However, I see nothing wrong with having a predefined operation that
> returns a suitable pool.
Yes.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2008-01-09 17:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-07 15:48 Ada containers and custom allocators Maciej Sobczak
2008-01-07 16:29 ` Dmitry A. Kazakov
2008-01-08 1:54 ` Randy Brukardt
2008-01-08 7:59 ` Maciej Sobczak
2008-01-08 23:54 ` Randy Brukardt
2008-01-09 8:56 ` Dmitry A. Kazakov
2008-01-09 15:29 ` Robert A Duff
2008-01-09 17:09 ` Dmitry A. Kazakov [this message]
2008-01-09 21:58 ` Robert A Duff
2008-01-10 10:12 ` Dmitry A. Kazakov
2008-01-11 5:00 ` Randy Brukardt
2008-01-09 15:28 ` Robert A Duff
2008-01-11 5:00 ` Randy Brukardt
2008-01-11 21:02 ` Maciej Sobczak
2008-01-11 22:41 ` Robert A Duff
2008-01-12 13:40 ` Maciej Sobczak
2008-01-12 15:59 ` Robert A Duff
2008-01-09 1:17 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox