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=-0.9 required=3.0 tests=BAYES_00,XPRIO autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: On absurdity of collections 7.6.1 (11.1/3) Date: Wed, 29 Sep 2021 19:23:28 -0500 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Thu, 30 Sep 2021 00:23:29 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="965"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:62874 List-Id: It's surely wrong, because you have to deallocate from the same pool as you allocated. And you have no way to save such a thing. There is no capability in Ada to use multiple pools with one access type. At best, you could directly call Allocate and Deallocate for this purpose, but it is impossible to use anything built-in. You could use the subpool mechanism (assuming you want a limited number of kinds of pools) to do this (each subpool could use a different allocation mechanism). But that would mean a giant pool type containing all of the implementations -- which seems suboptimal. Note that the subpool mechanism ensures that finalization happens when a subpool is destroyed. Randy. "Dmitry A. Kazakov" wrote in message news:sj1i6g$7hv$1@gioia.aioe.org... > On 2021-09-29 13:05, Simon Wright wrote: >> "Dmitry A. Kazakov" writes: >> >>> type Item_Ptr is access all Item; >>> function New_Item >>> ( Pool : in out Root_Storage_Pool'Class; >>> Text : String >>> ) return Item_Ptr; >> >> What I don't see is how you can implement this, never mind any other >> problems. > > A naive, but wrong due to 7.6.1 (11.1/3) nonsense, implementation would > be: > > function New_Item > ( Pool : in out Root_Storage_Pool'Class; > Text : String > ) return Item_Ptr is > type Ptr is access Item; > for Ptr'Storage_Pool use Pool; > Object : Ptr := new Item (Text'Length); > begin > Object.Text := Text; > return Object.all'Unchecked_Access; > end New_Item; > > -- > Regards, > Dmitry A. Kazakov > http://www.dmitry-kazakov.de