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.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,aa968038a51ee866 X-Google-Attributes: gid103376,public From: guerby@gnat.com (Laurent Guerby) Subject: Re: Q: Ada.Unchecked_Deallocation Date: 1996/07/21 Message-ID: #1/1 X-Deja-AN: 169307689 sender: guerby@schonberg.cs.nyu.edu references: <31E5D4D1.11DB36E1@jinx.sckans.edu> organization: New York University reply-to: guerby@gnat.com newsgroups: comp.lang.ada Date: 1996-07-21T00:00:00+00:00 List-Id: Robert> It would have to be VERY SMART! The body of Finalize appears Robert> in the package body and the client typically only sees the Robert> package spec. A "pragma Inline(Finalize);" can turn your Ada compiler in a VERY SMART one ;-). Once the compiler has seen the body, it can switch on the flag that would otherwise be set by the pragma. Robert> And also, this may require introducing Robert> conversions all over your program which you would prefer to ^^^^^^^^ Robert> avoid. It depends on your application, the conversions are needed when you assign local KLUNK objects to global KLUNK_Bis ones and vice-versa. All procedure calls are the same. If you find that your application spend too much time in useless finalization free calls, you turn all objects that don't need it to KLUNK_Bis, and you add conversions where your compiler tell you so (helpful strict type checking). Since this optimization is only helpful when your program is to be launched a great number of time, and that finalization time is not zero regarding to execution time, I guess an application needing this optimization won't be that large. An alternative design is to set a flag in the run-time saying "now, don't bother to call free", and to modify Ada.Unchecked_Deallocation to perform a free call only if this flag is not set (talking about GNAT implementation here, there's already a check against null). Of course this doesn't remove all the calls to Finalize, but if free calls are expensive on your system, that's enough. -- Laurent Guerby , Team Ada. "Use the Source, Luke. The Source will be with you, always (GPL)."