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


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




  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 ` 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-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
1996-07-21  0:00   ` Robert A Duff
1996-07-21  0:00   ` Laurent Guerby [this message]
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