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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f6ee8ca03c176d76 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-29 03:41:50 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!skynet.be!skynet.be!fu-berlin.de!uni-berlin.de!b984e.pppool.DE!not-for-mail From: Dmitry A.Kazakov Newsgroups: comp.lang.ada Subject: Re: stupid question: how can I finish a program? Date: Fri, 30 Aug 2002 00:48:41 +0200 Message-ID: References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: b984e.pppool.de (213.7.152.78) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1030617708 53863287 213.7.152.78 (16 [77047]) User-Agent: KNode/0.4 Xref: archiver1.google.com comp.lang.ada:28545 Date: 2002-08-30T00:48:41+02:00 List-Id: Robert A Duff wrote: > Dmitry A.Kazakov writes: > >> For example? Abort without any defined clean-up warranties absolutely >> nothing. >> >> Otherwise, some sort of "finalization" should be defined. For instance: >> known tasks killed, known memory returned. But (1) any sort of >> finalization could still hang up. > > If you're running under a proper operating system, then all resources > visible outside the program will be cleaned up when the program exits. > Therefore, there is no need for finalization to clean up such resources. > (I'm talking about the Ada finalization here.) But cleaning up the resources *is* a finalization. When a file is closed, some code has to be executed [no matter on which context]. So there is no difference in that respect between how Ada and how an OS does it. The actual difference is that Ada precisely specifies what "task abort" means. > Certainly, "exit" will > kill all tasks in the program and recover all memory. There is no need > for finalization to clean up resources internal to the program, either > -- the program is about to vanish. No OS can warranty that *all* external resources will be freed. The margin is very unsharf. What if the process starts some system service? Is that an external resource? > *Some* kinds of finalization might be broken by "exit". For example, if > some Finalize routine flushes a buffer to disk, and you want that buffer > flushed. So you can't blithely call "exit" without some global > knowledge of how finalization is used in your program. > > If you're not using an operating system then the story is very > different. > >>... (2) How to define it in a portable way (= in language >> terms)? > > Seems pretty straightforward to me. Just define a feature that halts > the program and doesn't run any finalization. That's clear, but what kind of external finalization has to be performed? Because you cannot warranty that *all* external resources will be freed, you should specify which ones will be. It is possible, but IMO very difficult. Alternatively, you can say that it warranties nothing. Then well, the external *portable* effect = "does nothing". Who might need that thing? > In an embedded system, > the appropriate implementation might be: > > <> goto Self; -- Regards, Dmitry Kazakov www.dmitry-kazakov.de