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!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: Extending a third party tagged type while adding finalization Date: Mon, 4 Dec 2017 14:54:19 -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> <037e7f02-9149-4648-b7c5-91f67c1c1961@googlegroups.com> Injection-Date: Mon, 4 Dec 2017 20:54:20 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="454"; 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:49367 Date: 2017-12-04T14:54:19-06:00 List-Id: "Jere" wrote in message news:037e7f02-9149-4648-b7c5-91f67c1c1961@googlegroups.com... > On Monday, November 27, 2017 at 8:55:19 PM UTC-5, Randy Brukardt wrote: >> "Jere" wrote in message >> ... >> >> 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). >> >> 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. > > Well, I am definitely not advocating that all tagged types need to be > controlled. I was just musing about whether there was a different way > to do it. The Ada Finalization method is very clunky and can be > limiting at times. There may not be a better way to do it. At the > end of the day, I find a lot of the errors our programmers make is > forgetting to put in a Create/Intialize or Clean_Up/Finalize call > on objects that do not have Controlled ancestors. It's a > maintenance headache, so I look for ways to try to remedy that via > design. My personal opinion is that all newly designed ADTs should be derived from Controlled (or Limited_Controlled, if limited), even if there is no immediate need for finalization. That's especially true if extensions are expected; one doesn't want to put unnecessary limitations on extensions. The sort things that can't afford to be controlled are those that aren't really ADTs anyway (think coordinates of a windows). Randy.