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: Prologue and epilogue aspects Date: Thu, 1 Feb 2018 17:47:32 -0600 Organization: JSA Research & Innovation Message-ID: References: Injection-Date: Thu, 1 Feb 2018 23:47:32 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="24232"; 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:50267 Date: 2018-02-01T17:47:32-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:p4ul5c$582$1@gioia.aioe.org... > On 01/02/2018 01:17, Randy Brukardt wrote: >> "Dmitry A. Kazakov" wrote in message >> news:p4sm09$126n$1@gioia.aioe.org... >>> On 30/01/2018 23:02, Randy Brukardt wrote: >> ... >>>> Huh? If there is no implicit finalization, then there is no need for >>>> controlled types at all, as they serve no purpose. (If you want to >>>> explicitly finalize things, you can define any subprogram for that >>>> purpose. >>> >>> "Implicit" meant called upon implicit destruction, e.g. when access >>> types >>> go out of the scope. That thing is not needed. I don't see other reason >>> for the Controlled_Interface to induce hidden components. >> >> (1) Subpools and mutable types also need lists of some sort to properly >> do >> finalization. > > No, they need not. The rule would be that all explicitly allocated objects > of Controlled_Interface must be explicitly deallocated. Yes, but you need a list to explicitly deallocate a subpool (as there are many objects in the subpool). Or you could just ban the use of subpools, but that's madness. >> (2) The reason for the "out of scope" rules is so that Finalization can >> be >> used for resource allocation beyond simply memory management. For >> instance, >> to return device (handles) to the OS when they won't be used any more. We >> felt that there shouldn't be any leaks in that. > > I don't see how the feature would help. The only practical case when it > takes effect is when exiting from the program. At that point it does not > matter anyway. It does if the underlying manager is primitive (as some RTOSes are) and there is no automatic closing of handles. (That was the case on CP/M and early MS-DOS, if one left files open when a program exited, they never got closed at all. Which could lead to data loss or resource exhaustion.) >> (3) I think you would have to ban nested access types (that can go out of >> scope before program end) that designate type with parts of this kind of >> controlled type, lest the allocation of such objects lead to guarenteed >> storage leaks (one doesn't want to use Unchecked_Deallocation if they >> don't >> have to). > > Of course I would let them leak. No implicit deallocation. OK, but that's not the way Ada handles types with Storage_Size specified. I'd rather they were illegal (most of the accessibility madness comes from allowing such types, and they're nearly useless). >> (4) Chains for all controlled objects work best with exception handling, >> as >> it isn't necessary to enter every scope to try to clean up objects, and >> in >> particular, one doesn't have to deal with the horror of partially >> initialized objects (whose initialization was interrupted by an >> exception). > > It is always a controlled object that goes out the scope. All dynamically > allocated controlled objects are in some kind of controlled container or > other controlled structure responsible to deallocate them. Everything > ultimately hooked on some scoped controlled object. That is the only sane > design, IMO. > >> To use your static implementation, you also have to use a static >> implementation of exceptions, and somehow keep track of initialization of >> objects (and every part of such objects) in each scope. > > Then the scope can maintain a list of objects it initialized. I see no > need to corrupt the object representation with list pointers in order to > merely roll back the stack. That's what I called "fiendishly complex". Sure, it can be done, but you have to have a handler in every master with none trivial objects (regardless of whether there is any explicit exception handlers, of even if there can be). With the exception handing in our compiler, that would be a horrible drag on performance even if no handlers were used (state snapshots would be needed for each implicit handler, and handlers block optimizations as well, so a lot of unneeded checks wouldn't be identified). The only practical way to that is similar to the way that AdaCore does that (for both finalization and exception handling), which would be a 2-3 man year effort for any compiler vendor that isn't already using that scheme (so far as I know, that's most of the non-AdaCore vendors). And I doubt that even the AdaCore scheme quite matches to your goals. Plus the lack of safety (there now are many ways to get skip finalization on objects), I don't see anyone being very interested. It makes more sense, honestly, to support full multiple inheritance. Randy.