From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!Hx95GBhnJb0Xc8StPhH8AA.user.46.165.242.91.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Custom Storage Pool questions Date: Tue, 14 Sep 2021 08:23:08 +0200 Organization: Aioe.org NNTP Server Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: gioia.aioe.org; logging-data="43228"; posting-host="Hx95GBhnJb0Xc8StPhH8AA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:62730 List-Id: On 2021-09-14 02:48, Jere wrote: > Yes, but if you look at that blog, they are allocating space for the /user/ data > and for the Next/Prev for controlled types and First/Last for unconstrained > arrays in addition to the size specified by allocate. I do not understand your concern. The blog discusses how to add service data to the objects allocated in the pool. I use such pools extensively in Simple Components. E.g. linked lists are implemented this way. The list links are allocated in front of list elements which can be of any type, unconstrained arrays included. The problem with unconstrained arrays is not that the bounds are not allocated, they are, but the semantics of X'Address when applied to arrays. A'Address is the address of the first array element, not of the array object. For a pool designer it constitutes a problem of getting the array object by address. This is what Emmanuel discusses in the blog. [ The motivation behind Ada choice was probably to keep the semantics implementation-independent. ] Consider for example a list of String elements. When Allocate is called with String, it returns the address of all String. But that is not the address you would get if you applied 'Address. You have to add/subtract some offset in order to get one from another. In Simple Components this offset is determined at run-time for each generic instance. Of course, a proper solution would be fixing Ada by adding another address attribute: X'Object_Address returning the first address of the object as allocated. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de