comp.lang.ada
 help / color / mirror / Atom feed
From: aschwarz@acm.org (skidmarks)
Subject: Re: address/access/pointer confusion
Date: 20 Oct 2004 11:51:31 -0700
Date: 2004-10-20T11:51:31-07:00	[thread overview]
Message-ID: <35f054ea.0410201051.78cc61a0@posting.google.com> (raw)
In-Reply-To: 1c2f5137.0410200556.70a1518c@posting.google.com

> I think that not the same definition??
> Can anybody tell me the exact difference between pointer in C++ and
> access/address types in Ada???

(From dialogs on comp.lang.ada):

A C/C++ pointer is an address to an object. The object contains no
compiler provided information concerning it's semantics (and the
application can reinterpret the semantics freely using a cast).

An Ada Access Type is a pointer to an Ada representation of an object.
This representation can be an object, a la C/C++, or a pointer to a
dope vector providing semantic content of the object (and perhaps
other things - I'm not an Ada afficionado). The compiler vendor is
free to choose the interpretation and meaning of an Access Type
subject to the LRM.

Ad Ada Address is a pointer in the same sense as a C/C++ pointer, with
similar operations and interpretation. The proviso is that the Address
can (presumably) point to a dope vector (I need clarification on this)
but may also point to a raw object.

As an example:
    C/C++:     int a[20];
               int *p  = a;
               int *p1 = &a[0];

               // p == p1 == &a[0] the address of the first item in
the
                                   array a (by definition &a == &a(0))

    Ada:       type Arg        is array( 0 .. 19 O of Integer;
               type Arg_Access is access all Arg;
               a  : aliased Arg;
               p  : Arg_Access     := a'Access;
               p1 : System.Address := a(0)'Address;

               -- p /= p1 in general
               -- One representation of 'a' could be:
               -- a  => <<size of a><pointer to space for a>> --> a(0)
               -- p  => points to the 'a' dope vector (above)
               -- p1 => points to the first element of a, a(0)
               -- 
               -- In this case, p1 is equivalent to the C/C++ p, p1,
               --               p  has no C/C++ equivalency

I think I've got it correct. No doubt someone more knowledgeable will
fill in the edges if there are any errors.

art



  parent reply	other threads:[~2004-10-20 18:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-20 13:56 address/access/pointer confusion Hans Van den Eynden
2004-10-20 16:55 ` Martin Krischik
2004-10-20 18:51 ` skidmarks [this message]
2004-10-20 23:37   ` Georg Bauhaus
2004-10-21  7:30   ` Jacob Sparre Andersen
2004-10-22  1:14     ` Jeffrey Carter
replies disabled

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