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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Prologue and epilogue aspects Date: Thu, 1 Feb 2018 10:03:40 +0100 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:50243 Date: 2018-02-01T10:03:40+01:00 List-Id: 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. > (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. > (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. > (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. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de