experchange > ada

ldries46 (12-06-18, 08:25 AM)
What is the principal difference between the Attributes 'ADDRESS and
'ACCESS? When do you use them?
Dmitry A. Kazakov (12-06-18, 11:56 AM)
On 2018-12-06 07:25, ldries46 wrote:
> What is the principal difference between the Attributes 'ADDRESS and
> 'ACCESS? When do you use them?


1. Access is portable, Address is not. However across machines with flat
memory Address might be as good as portable.

2. Access is strongly typed, Address is untyped. Furthermore access
supports dispatching and class-wide calls as expected.

3. Access is memory pool aware, Address is blind to whatever memory
management policy.

4. Access could work around some machine limitations address cannot.
E.g. access could, theoretically, refer to things that do not have
physical address, like packed data, data outside conventional memory etc.

5. Access is a subject of accessibility checks and other constraints,
e.g. "not null". Not everybody sees all these as an advantage, but in
some cases it might help to generate safer and more efficient code.
Jeffrey R. Carter (12-06-18, 06:43 PM)
On 12/6/18 7:25 AM, ldries46 wrote:
> What is the principal difference between the Attributes 'ADDRESS and 'ACCESS?
> When do you use them?


The principal difference is that 'Address returns a value of type System.Address
and 'Access returns a value of an access type. They are not the same and there
is not necessarily any relationship between them.

From ARM K.2(2-7) Language-Defined Attributes:

2
P'Access
For a prefix P that denotes a subprogram:
3
P'Access yields an access value that designates the subprogram denoted by P. The
type of P'Access is an access-to-subprogram type (S), as determined by the
expected type. See 3.10.2.
4
X'Access
For a prefix X that denotes an aliased view of an object:
5
X'Access yields an access value that designates the object denoted by X. The
type of X'Access is an access-to-object type, as determined by the expected
type. The expected type shall be a general access type. See 3.10.2.
6/1
X'Address
For a prefix X that denotes an object, program unit, or label:
7
Denotes the address of the first of the storage elements allocated to X. For a
program unit or label, this value refers to the machine code associated with the
corresponding body or statement. The value of this attribute is of type
System.Address. See 13.3.

Similar Threads