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!news2.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 Supersedes: <87k4niiutt.fsf@mid.deneb.enyo.de> Date: Sun, 22 Aug 2010 17:09:29 +0200 Message-ID: <87r5hqhefq.fsf@mid.deneb.enyo.de> References: <8762z4gcoi.fsf@mid.deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: idssi.enyo.de 1282489769 28289 172.17.135.6 (22 Aug 2010 15:09:29 GMT) X-Complaints-To: news@enyo.de Cancel-Key: sha1:mU5rQolTUzha2zZD6w+CyMYARXk= Cancel-Lock: sha1:N/QM7TKq3px0aRsG/od5oJHP3Cw= Xref: g2news1.google.com comp.lang.ada:13611 Date: 2010-08-22T17:09:29+02:00 List-Id: > I don't quite why this needs an extra pragma -- your example is, > apparently, easy to handle by current Ada's capacities: > > procedure New_Test_External_Formats is > ... > COBOL_File : File_Type; > > procedure Close_Cobol_File is > begin > Close(COBOL_FILE); > end Close_Cobol_File; > > Finisher: Finish_Package.Finisher; > -- The type Finish_Package.Finisher is derived from > -- Ada.Finalization.Limited_Controlled. > ... Or even this: COBOL_File : File_Type; package Finisher_COBOL_File is new Finisher (File_Type, COBOL_File, Close); That's actually quite nice, and can be implemented in Ada 2005. Unfortunately, GNAT still generates horrible code for this case, but that can be fixed. (One trivial improvement is to use your Finisher type in the implementation of the Finisher package; further improvements need some compiler work.)