comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Q: Ada.Unchecked_Deallocation
Date: 1996/07/21
Date: 1996-07-21T00:00:00+00:00	[thread overview]
Message-ID: <DuwnGt.Bz2@world.std.com> (raw)
In-Reply-To: ws9zq4un5ni.fsf@schonberg.cs.nyu.edu


In article <ws9zq4un5ni.fsf@schonberg.cs.nyu.edu>,
Laurent Guerby <guerby@gnat.com> 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




  parent reply	other threads:[~1996-07-21  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 ` Ron Thompson
1996-07-13  0:00   ` Robert Dewar
1996-07-21  0:00     ` Robert A Duff
1996-07-12  0:00 ` Jon S Anthony
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
1996-07-20  0:00     ` Robert Dewar
1996-07-21  0:00     ` Robert A Duff [this message]
1996-07-21  0:00   ` Robert A Duff
1996-07-21  0:00   ` Laurent Guerby
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