comp.lang.ada
 help / color / mirror / Atom feed
From: sun-barr!cs.utexas.edu!usc!rpi!bu.edu!inmet!inmet!spock!stt@ames.arc.nasa
Subject: Re: Pointer help
Date: 27 Apr 92 16:39:00 GMT	[thread overview]
Message-ID: <20600134@spock> (raw)

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

             reply	other threads:[~1992-04-27 16:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-04-27 16:39 sun-barr!cs.utexas.edu!usc!rpi!bu.edu!inmet!inmet!spock!stt [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-04-20 15:42 Pointer help David Emery
1992-04-16 20:59 dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!wupost!usc!rpi!sarah!c
1992-04-16 18:52 iggy.GW.Vitalink.COM!psinntp!psinntp!vitro.com!v7.vitro.com!eswgcc
replies disabled

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