From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Examining individual bytes of an integer Date: Wed, 17 Oct 2018 12:04:21 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <9d90fa3e-f800-4086-bf97-a65474a8140a@googlegroups.com> <4ddbc9bf-0e2e-466d-8238-d8f709b985e1@googlegroups.com> <35f53cd9-4979-49b8-a5df-2c1cf0764507@googlegroups.com> <138eb1d1-dba4-46a3-aaa3-4505750b3384@googlegroups.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.3 Xref: reader02.eternal-september.org comp.lang.ada:54616 Date: 2018-10-17T12:04:21+02:00 List-Id: On 2018-10-17 11:47, briot.emmanuel@gmail.com wrote: >> Meaning the first address of the object, e.g. of the dope of an >> indefinite array as it was returned by the allocator: >> >> Allocation_Address := Pointer_To_Object.all'Address - Offset; >> >> Presently the offset to the object beginning must be estimated during >> run-time. > > GNATCOLL has a package GNATCOLL.Storage_Pools.Headers which does some similar > low-level tricks. > When you use this storage pool, it will allocate extra bytes (for a header type that you > provide), before the object'Address. Right, this is the major use case: to allocate something in front of each object. > GNATCOLL uses it for instance to store reference counting information without impacting > the declaration of objects, or changing what their 'Address means. I have an implementation of the linked list with links allocated in pool so that the list nodes have the type the original object as-is. Same approach. P.S. It is kind of multiple inheritance for poor. Reference counts or links are "inherited" into the object's representation in the pool. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de