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!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.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: Extending a third party tagged type while adding finalization Date: Mon, 27 Nov 2017 19:55:18 -0600 Organization: JSA Research & Innovation Message-ID: References: <4db43571-7f86-4e73-8849-c41160927703@googlegroups.com> <6496a10f-c97e-4e42-b295-2478ad464b2f@googlegroups.com> <6106dfe6-c614-4fc1-aace-74bf8d7435e3@googlegroups.com> <24767ee5-cda8-45e4-98d1-7da44757bd40@googlegroups.com> Injection-Date: Tue, 28 Nov 2017 01:55:18 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="15588"; 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; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:49210 Date: 2017-11-27T19:55:18-06:00 List-Id: "Shark8" wrote in message news:24767ee5-cda8-45e4-98d1-7da44757bd40@googlegroups.com... ... >> Based on what I have read so far, I didn't see any discussion that would >> lead me to think this will be changed at least in the near future. I >> wish there was a way it would be easy for vendors to do something like: >> >> type Some_Type is tagged private; >> for Some_Type'Initialize use Initialize_Some_Type; >> for Some_Type'Adjust use Adjust_Some_Type; >> for Some_Type'Finalize use Finalize_Some_Type; >> >> and then just have the compiler handle adding the needed structures >> to the type under the hood (like how GNAT uses Controlled to hold >> a linked list under the hood...but compiler managed). This sort of thing might work in GNAT, but it would be completely impossible in Janus/Ada. We used an implementation strategy that follows directly from the Ada definition: there are hidden components that belong to type Ada.Finalization.Controlled, and the tag of that type has additional slots to support Initialize/Adjust/Finalize. Objects of controlled types get added to a linked list (that's what the hidden components are for), and Finalization happens by dispatching to the Finalize routine for each object on that list at the appropriate point. A mechanism like the above would require adding those hidden components (which have to be at a fixed location, lest it be impossible to walk the linked list) to existing types, which would require moving components. That has no chance of working. Keep in mind that the full type above might be declared something like: type Some_Type is new Some_Other_Type with null record; where Some_Other_Type already has components that are declared in the same place as the controlled components. The only way this could be made to work in Janus/Ada would be for all tagged types to be controlled, which would waste time and space for types that aren't actually controlled. Since Janus/Ada was designed to be space-efficient, that would be going directly against our primary goal - not something I'd do without a fight. Randy.