From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c8360a2ce0e343cc X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews1.google.com!not-for-mail From: aschwarz@acm.org (skidmarks) Newsgroups: comp.lang.ada Subject: Re: address/access/pointer confusion Date: 20 Oct 2004 11:51:31 -0700 Organization: http://groups.google.com Message-ID: <35f054ea.0410201051.78cc61a0@posting.google.com> References: <1c2f5137.0410200556.70a1518c@posting.google.com> NNTP-Posting-Host: 199.46.200.233 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1098298291 20866 127.0.0.1 (20 Oct 2004 18:51:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Oct 2004 18:51:31 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:5540 Date: 2004-10-20T11:51:31-07:00 List-Id: > 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 => <> --> 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