From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 27 Apr 92 16:39:00 GMT From: sun-barr!cs.utexas.edu!usc!rpi!bu.edu!inmet!inmet!spock!stt@ames.arc.nasa .gov Subject: Re: Pointer help Message-ID: <20600134@spock> List-Id: Re: Creating an access value designating a declared object. As Dave Emery suggests, in the proposed Ada 9X revision, one may create an access value designating a declared object using the ACCESS attribute, but only if the object is marked "aliased" in its declaration. (This feature did "make the cut" through the various rounds of simplification.) Here is a simple example: type Rec_Type is record ... end record; type Ptr_Type is access all Rec_Type; -- the "all" indicates that -- this is a "general" access -- type that is allowed to -- point at "aliased" declared -- objects R : aliased Rec_Type; -- Here is an object that may be pointed-to -- (because it is marked aliased). X : Ptr_Type := R'ACCESS; -- Declare a pointer and initialize it -- to point at R. Using 'ADDRESS and unchecked conversion works in most, but not all Ada 83 compilers. It fails in compilers where access types are shorter than full addresses (e.g. on the 1750A with expanded memory, the Rational, and some 80x86 compilers). Vendors often provide some alternative approach if the unchecked conversion approach won't work. The Ada 9X approach requires both that the access type be special (i.e. marked as a "general" access type with the keyword "all"), and that the designated object be special (i.e. marked with "aliased"). This is intended to preserve upward compatibility of efficiency, so that non-general access types may still be shorter than full addresses, and non-aliased objects may be allocated in registers rather than real memory. In addition, an optimizer "knows" that only aliased objects can be affected by stores through general access values. The keyword "aliased" may also appear on record component declarations and on the component subtype indication for an array type, to allow pointers to designate aliased components of composite objects. -S. Tucker Taft Ada 9X Mapping/Revision Team (ada9x-mrt@inmet.com) Intermetrics, Inc. Cambridge, MA 02138