Re: memory management
- From: Robert A Duff <bobduff@xxxxxxxxxxxxxxxxxxxx>
- Date: 28 May 2005 07:44:16 -0400
Martin Krischik <krischik@xxxxxxxxxxxxxxxxxxxxx> writes:
> Robert A Duff wrote:
>
> > alex goldman <hello@xxxxxxxx> 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
.
- Follow-Ups:
- Re: memory management
- From: Simon Wright
- Re: memory management
- References:
- memory management
- From: alex goldman
- Re: memory management
- From: Robert A Duff
- Re: memory management
- From: Martin Krischik
- memory management
- Prev by Date: Re: memory management
- Next by Date: Re: memory management
- Previous by thread: Re: memory management
- Next by thread: Re: memory management
- Index(es):
Relevant Pages
|