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!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: ANN: PLplot plotting library with Ada bindings Date: Fri, 18 Oct 2013 21:27:50 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <61b58fde-2542-485a-a5e8-c7041ad822bd@googlegroups.com> <9006bf4b-e682-4803-a5e3-b0363ecb61d1@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1382149671 28313 69.95.181.76 (19 Oct 2013 02:27:51 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 19 Oct 2013 02:27:51 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:17466 Date: 2013-10-18T21:27:50-05:00 List-Id: "Jerry" wrote in message news:9006bf4b-e682-4803-a5e3-b0363ecb61d1@googlegroups.com... On Tuesday, October 1, 2013 5:45:57 PM UTC-7, Jeffrey Carter wrote: > On 10/01/2013 05:31 PM, Jerry wrote: ... >> > ... >> > End_PLplot; -- Call this only once. >> >> Why not use finalization to do this? > >... >I don't know what happens if the library doesn't get finalized but it >probably ties up >resources so an automatic process would be wise in that sense. The problem with requiring manual finalization is that it doesn't work when the program propagates an exception. In that case, the user's explicit call doesn't get executed. You could try to require them to handle such exceptions and do the finalization in a handler, but that's both a mess and something that's easy to forget. And even that doesn't work in the face of abort (although that's probably not a significant concern in this case). Thus, I think you always want automatic finalization if any is needed. It might make sense to also support a manual version (especially in this case, where you wouldn't want to force an incompatibility on any of your users, which you would if you completely got rid of the End_PLPlot routine.) -- but you don't want that manual version to be required. (Of course, this assumes that the finalization actually does something important; if the OS cleans up well enough after an program that terminated unexpectedly, then this doesn't apply.) Even if *correct* programs would be fine with manual finalization, remember that the program will fail many times while you're creating and debugging it. You don't want that to suck up resources on the user's computer. Randy.