Jump to content

Ada Programming/Attributes/'Access

From Wikibooks, open books for an open world

Ada. Time-tested, safe and secure.
Ada. Time-tested, safe and secure.

Description

[edit | edit source]

X'Access is an Ada attribute where X is any object or subprogram.

'Access may be used to return an access value designating the object or subprogram.

Example

[edit | edit source]
 type General_Pointer  is access all      Integer;
 type Constant_Pointer is access constant Integer;

 I1: aliased constant Integer := 10;
 I2: aliased Integer;

 P1: General_Pointer  := I1'Access;  -- illegal
 P2: Constant_Pointer := I1'Access;  -- OK, read only
 P3: General_Pointer  := I2'Access;  -- OK, read and write
 P4: Constant_Pointer := I2'Access;  -- OK, read only

 P5: constant General_Pointer := I2'Access;  -- read and write only to I2
 type Callback_Procedure is access procedure (Id  : Integer;
                                             Text: String);
 procedure Process_Event (Id  : Integer;
                         Text: String);

 My_Callback: Callback_Procedure := Process_Event'Access;

See also

[edit | edit source]

Wikibook

[edit | edit source]

Ada Reference Manual

[edit | edit source]