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.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: bobduff@world.std.com (Robert A Duff) Subject: Re: Q: Ada.Unchecked_Deallocation Date: 1996/07/21 Message-ID: #1/1 X-Deja-AN: 170595625 references: <31E5D4D1.11DB36E1@jinx.sckans.edu> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-07-21T00:00:00+00:00 List-Id: In article , Laurent Guerby wrote: > 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. This would have to be a link-time optimization. Instead, do it the other way around: Define the no-finalize version first, and then derive the finalized version from that. Then, the compiler *can* tell (at compile time) that the first type has null Finalize, since it doesn't override the known-null version inherited from type Controlled. Either way, you have to be careful, though. You can't declare nested objects of the no-finalize type, or you'll get a storage leak. And what if it's in a generic package, which is *sometimes* instantiated in a nested place? - Bob