comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: memory management
Date: 28 May 2005 07:44:16 -0400
Date: 2005-05-28T07:44:16-04:00	[thread overview]
Message-ID: <wccoeav8tin.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: 1226363.QsRZW1KHie@linux1.krischik.com

Martin Krischik <krischik@users.sourceforge.net> writes:

> Robert A Duff wrote:
> 
> > alex goldman <hello@spamm.er> writes:
> > 
> >> As I understood from reading the Ada tutorial for C/C++ programmers,
> >> "access" is essentially like C++ smart pointer,
> > 
> > No, Ada access types are just pointers -- no "smarts".
> > To make something like smart pointers, you can use
> > controlled types.
> 
> No again - any paricular Ada implementation is free to implement access
> types as they see fit. With GNAT an access may consist of an pointer to the
> data and a pointer to a dope vector:

That's what I call a "fat pointer".  Still just a pointer (as opposed to
a smart pointer).

When I say "pointer", I don't mean it has to be implemented as a single
machine address.  It could be an offset from some known base address, an
index into an array, or (as you say) a fat pointer -- among other
things.

The same is true of pointers in C and C++ -- an implementation is free
to implement pointers as something other than a machine address.  In
fact, if a C compiler wishes to check array bounds, it pretty much *has*
to use fat pointers.  I know of one C compiler that did just that.  My
point is that "pointer" is not synonymous with "single machine address",
even in C.

By the way, I believe the fat pointers used by GNAT are an option --
there's some way to tell it to use thin pointers for access-to-array.
GNAT uses fat pointers (by default) only when the designated type is an
array, or when the designated type is unknown to the compiler.
Access-to-record, which is far more common, uses thin pointers.
I don't know of any Ada implementation besides GNAT that uses
fat pointers at all.

> http://en.wikipedia.org/wiki/Dope_vector

> Remeber that an Ada compiler may also implement garbage collection.

Yes.  That would typically *not* involve smart pointers.

- Bob



  reply	other threads:[~2005-05-28 11:44 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-26  0:57 memory management alex goldman
2005-05-26  2:14 ` David C. Hoos, Sr.
2005-05-26 13:21   ` Steve
2005-05-26 18:40     ` alex goldman
2005-05-28  2:13       ` Steve
2005-05-28  5:19         ` Jeffrey Carter
2005-05-28 14:48           ` Steve
2005-05-26 18:47     ` Pascal Obry
2005-05-27 14:33   ` Martin Krischik
2005-05-26 12:10 ` Robert A Duff
2005-05-27 14:31   ` Martin Krischik
2005-05-28 11:44     ` Robert A Duff [this message]
2005-05-28 13:03       ` Simon Wright
2005-05-31 12:04         ` Robert A Duff
2005-06-02 15:42       ` Thomas Maier-Komor
2005-06-02 17:05         ` Robert A Duff
2005-06-03  1:41       ` Steve
2005-06-03 10:12         ` alex goldman
2005-06-13  4:01         ` Dave Thompson
  -- strict thread matches above, loose matches on Subject: below --
2005-04-19 20:30 Memory_Management Anh Vo
2005-04-19  1:39 Memory_Management Bini
2005-04-19  9:18 ` Memory_Management Duncan Sands
2005-04-20  1:06   ` Memory_Management Bini
replies disabled

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