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/20 Message-ID: #1/1 X-Deja-AN: 169071902 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-20T00:00:00+00:00 List-Id: Robert> One: suppose we declare a type KLUNK that has a complex Robert> finalize routine that frees a KLUNK and all its descendences. Robert> Now if I have a type Robert> type AKLUNK is access KLUNK Robert> then when I allocate objects of type KLUNK using this access Robert> type, they will be freed using by complex finalize routine Robert> when I leave the program, and it is this global finalization Robert> that I wish to avoid, but of course I still need a Robert> finalization routine for cases where objects of type KLUNK are Robert> allocated locally. What about (in Ada 95 without extension): type KLUNK_WITH_EMPTY_FINALIZE is new KLUNK with null record; procedure Finalize (Obj : KLUNK) is begin null; end Finalize; And instead of applying the pragma, you declare objects of this new type. A smart compiler can optimize away calls to such a Finalize subprogram. -- Laurent Guerby , Team Ada. "Use the Source, Luke. The Source will be with you, always (GPL)."