comp.lang.ada
 help / color / mirror / Atom feed
From: Florian Weimer <fw@cygnus.stuttgart.netsurf.de>
Subject: Re: Which is right here - GNAT or OA ?
Date: 1999/06/05
Date: 1999-06-05T12:13:42+00:00	[thread overview]
Message-ID: <m3pv3au9op.fsf@deneb.cygnus.stuttgart.netsurf.de> (raw)
In-Reply-To: 928529202.956.79@news.remarQ.com

"Vladimir Olensky" <vladimir_olensky@yahoo.com> writes:

> When Free(X) is invoked then RTS  could do something like this  (in reality
> it may be much more complex):

[Heuristics based on the internal access value representation snipped]

> Such solution have very little  overhead and it is not very difficult to
> be implemented.

Maybe that's true, but it does not work.  Consider the following
situation:

   type A is record
      X: Integer;
   end record;

   type B is record
     Y: aliased A;
   end record;
   
   type B_Access is access B;

   Z: B_Access := new B;
                        
Your heuristics fails for Z.Y'Access, because this access
value references an object which has been created indirectly by
an allocator.  On all architectures I can imagine, the internal
machine representation of Z.Y'Access will look very like that of an
access to an object which has been directly created by an allocator,
although the value of Z.Y'Access certainly isn't a valid argument for
Ada.Unchecked_Deallocation.

Of course, it is possible to ensure that Ada.Unchecked_Deallocation
raises an exception if it encounters an access-to-variable, but this
requires some non-trivial changes.  A few possible implementations come
to my mind: colored pointers, fat pointers, hidden record fields (your
suggestion; problematic with scalar types and possibly with records
with representation clauses, also some space concerns), colored tags
for tagged records, support from a garbage collector.  They all don't
seem very appealing to me and probably won't handle all kinds of Ada
objects consistently (except perhaps garbage collection ;).

One very reasonable way to solve this kind of problem was already
pointed out: Use an abstract data type which hides allocation and
deallocation details in the implementation.  This way, you never have to
call Ada.Unchecked_Deallocation directly (outside the implementation,
of course), and you can't accidently deallocate an object which isn't
located in a storage pool.




  reply	other threads:[~1999-06-05  0:00 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-30  0:00 Which is right here - GNAT or OA ? Vladimir Olensky
1999-05-30  0:00 ` Robert Dewar
1999-05-31  0:00   ` Vladimir Olensky
1999-05-31  0:00     ` Robert Dewar
1999-06-01  0:00   ` dennison
1999-05-30  0:00 ` Florian Weimer
1999-05-31  0:00   ` Vladimir Olensky
1999-05-31  0:00     ` Robert Dewar
1999-06-05  0:00       ` Vladimir Olensky
1999-06-05  0:00         ` Florian Weimer [this message]
1999-06-05  0:00         ` Vladimir Olensky
1999-06-05  0:00           ` Robert Dewar
1999-06-07  0:00             ` Ada safety road Was: Which is right Vladimir Olensky
1999-06-06  0:00               ` Larry Kilgallen
1999-06-07  0:00                 ` Keith Thompson
1999-06-07  0:00                   ` Hyman Rosen
1999-06-08  0:00                     ` Robert A Duff
1999-06-08  0:00                       ` Robert Dewar
1999-06-08  0:00                       ` Keith Thompson
1999-06-09  0:00                         ` dennison
1999-06-09  0:00                           ` Entamology of "Nasal Demons" dennison
1999-06-09  0:00                         ` Ada safety road Was: Which is right Robert Dewar
1999-06-09  0:00                           ` Tucker Taft
1999-06-09  0:00                             ` Robert Dewar
1999-06-09  0:00                       ` dennison
1999-06-08  0:00                   ` Robert Dewar
1999-06-07  0:00                     ` Keith Thompson
1999-06-08  0:00                     ` Robert A Duff
1999-06-08  0:00                   ` Robert A Duff
1999-06-14  0:00                   ` Ada safety road Franco Mazzanti
1999-06-15  0:00                     ` Franco Mazzanti
1999-06-16  0:00                       ` Vladimir Olensky
1999-06-06  0:00               ` Ada safety road Was: Which is right Robert Dewar
1999-06-07  0:00                 ` Pascal F. Martin
1999-06-07  0:00                   ` Vladimir Olensky
1999-06-08  0:00                 ` Robert A Duff
1999-06-10  0:00               ` Peter Amey
1999-06-10  0:00                 ` Markus Kuhn
1999-06-11  0:00                   ` Vladimir Olensky
1999-06-12  0:00                     ` Robert Dewar
1999-06-12  0:00                       ` JP Thornley
1999-06-13  0:00                         ` Vladimir Olensky
1999-06-16  0:00                         ` William Dale
1999-06-19  0:00                           ` JP Thornley
1999-06-21  0:00                           ` Robert A Duff
1999-06-13  0:00                       ` Vladimir Olensky
1999-06-12  0:00                         ` Matthew Heaney
1999-06-13  0:00                           ` Vladimir Olensky
1999-06-13  0:00                         ` Robert Dewar
1999-06-13  0:00                           ` swhalen
1999-06-13  0:00                           ` Vladimir Olensky
1999-06-13  0:00                         ` Robert Dewar
1999-06-13  0:00                           ` Vladimir Olensky
1999-06-01  0:00   ` Which is right here - GNAT or OA ? Tucker Taft
1999-05-31  0:00 ` David Botton
1999-06-01  0:00   ` dennison
1999-06-03  0:00 ` Matthew Heaney
replies disabled

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