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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7fcf9180e7ba7ab1 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!feeder.erje.net!news.internetdienste.de!newsfeed.velia.net!news.tu-darmstadt.de!news.belwue.de!LF.net!news.enyo.de!not-for-mail From: Florian Weimer Newsgroups: comp.lang.ada Subject: Re: A suggestion for resource management Date: Sat, 21 Aug 2010 23:09:38 +0200 Message-ID: <8739u73c6l.fsf@mid.deneb.enyo.de> References: <8762z4gcoi.fsf@mid.deneb.enyo.de> <1q8io375n581c$.7mbvmavnyzyy$.dlg@40tude.net> <87d3tb7npi.fsf@mid.deneb.enyo.de> <18bfxkfl1kjy0$.4vebp50shxrp$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: idssi.enyo.de 1282424978 7467 172.17.135.6 (21 Aug 2010 21:09:38 GMT) X-Complaints-To: news@enyo.de Cancel-Lock: sha1:itJQVcHWzEbF/nD4r7fUucjLY3g= Xref: g2news1.google.com comp.lang.ada:13586 Date: 2010-08-21T23:09:38+02:00 List-Id: * Dmitry A. Kazakov: >> You can't always change libraries in that way. Adding destructors has >> both syntactic and run-time overhead. > > I don't see why. Without class-wide objects there is no overhead, > everything is statically known. You need escape analysis or inter-procedural scalar replacement to eliminate the tag. But it certainly can be done, and the additional word will not hurt in all but the most extreme cases. (There's a GNAT-specific inefficiency, but it is reportedly being tackled.) > BTW, file handle File_Type should not be opened, it should be > constructed. There should be no invalid File_Type, There are cases where you need the explicit Close operation, so you still end up with an invalid state. How would you handle an exception raised by construction, without extending the handler to cover undue regions of code? >> There are some cases where the destructor solution doesn't really >> apply. For instance, the cleanup operation might need two parameters, >> one denoting the object, and a second one decribing where to put it. > > I would use mix-in in such rare cases. However, I try to avoid clean-ups. > It is a bad pattern. And you suggest to use Finalize procedures instead? Hmm.