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: a07f3367d7,4083771199667fd1,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!news.tu-darmstadt.de!news.belwue.de!LF.net!news.enyo.de!not-for-mail From: Florian Weimer Newsgroups: comp.lang.ada Subject: Ensuring resource cleanup Date: Mon, 08 Feb 2010 15:16:12 +0100 Message-ID: <87zl3jertf.fsf@mid.deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: idssi.enyo.de 1265638572 30924 212.9.189.177 (8 Feb 2010 14:16:12 GMT) X-Complaints-To: news@enyo.de Cancel-Lock: sha1:MIA+ijl7WppW90gvDtOnTeE5XyU= Xref: g2news1.google.com comp.lang.ada:8979 Date: 2010-02-08T15:16:12+01:00 List-Id: It looks as if I might need to do some Ada maintenance programming soon. I can use the GNAT from GCC 4.3. Are there any new ways to ensure resource cleanup? I tried to use Ada.Finalization.Limited_Controlled in the past, but there were several issues with it: there was some run-time overhead (because of the tag and because the finalizer is abort-deferred, which seemed to defeat inlining and scalar replacement of aggregates), it was impossible to instantiate generics containing such types below the library level, and having multiple different types inherting from Limited_Controled in the same package often resulted in multi-dispatch errors (and using 'Class required exposing the tagged nature of the type in the interface, with has other drawbacks). Explicit cleanup using cleanup subprograms is okay, too, provided that there is some tool to ensure that they are used properly. This is despite the rather cumbersome syntax: declare X : Object; begin Init (X); begin Make_Use_Of (X); exception when others => Cleanup (X); raise; end; Cleanup (X); end; But I'd really have a tool that ensures that Init and Cleanup calls are properly paired in this way. Are there other approaches I don't know about yet?