comp.lang.ada
 help / color / mirror / Atom feed
From: guerby@gnat.com (Laurent Guerby)
Subject: Re: Q: Ada.Unchecked_Deallocation
Date: 1996/07/20
Date: 1996-07-20T00:00:00+00:00	[thread overview]
Message-ID: <ws9zq4un5ni.fsf@schonberg.cs.nyu.edu> (raw)
In-Reply-To: dewar.837178582@schonberg


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 <guerby@gnat.com>, Team Ada.
   "Use the Source, Luke. The Source will be with you, always (GPL)."




  parent reply	other threads:[~1996-07-20  0:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-11  0:00 Q: Ada.Unchecked_Deallocation David Morton
1996-07-12  0:00 ` Robert Dewar
1996-07-16  0:00   ` Robert I. Eachus
1996-07-21  0:00     ` Robert A Duff
1996-07-20  0:00   ` Laurent Guerby [this message]
1996-07-20  0:00     ` Robert Dewar
1996-07-21  0:00     ` Robert A Duff
1996-07-21  0:00   ` Robert A Duff
1996-07-21  0:00   ` Laurent Guerby
1996-07-12  0:00 ` Jon S Anthony
1996-07-12  0:00 ` Ron Thompson
1996-07-13  0:00   ` Robert Dewar
1996-07-21  0:00     ` Robert A Duff
1996-07-14  0:00 ` Andy Askey
1996-07-14  0:00   ` Robert Dewar
1996-07-27  0:00     ` Uri Shina
1996-07-30  0:00       ` Theodore E. Dennison
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox