Ada Reference Manual (Ada 2022) — Legal Information

# 12.5.4 Formal Access Types

1/2
The category determined for a formal access type is the category of all access types.

#### Syntax

2
formal_access_type_definition ::= access_type_definition

#### Legality Rules

3
For a formal access-to-object type, the designated subtypes of the formal and actual types shall statically match.
4/2
If and only if the general_access_modifier constant applies to the formal, the actual shall be an access-to-constant type. If the general_access_modifier all applies to the formal, then the actual shall be a general access-to-variable type (see 3.10). If and only if the formal subtype excludes null, the actual subtype shall exclude null.
5/3
For a formal access-to-subprogram subtype, the designated profiles of the formal and the actual shall be subtype conformant.

#### Examples

6
Example of formal access types:
7
-- the formal types of the generic package
8
generic
type Node is private;
type Link is access Node;
package P is
...
end P;
9
-- can be matched by the actual types
10
type Car;
type Car_Name is access Car;
11
type Car is
record
Pred, Succ : Car_Name;
Number : License_Number;
Owner : Person;
end record;
12
-- in the following generic instantiation
13
package R is new P(Node => Car, Link => Car_Name);

Ada 2005 and 2012 Editions sponsored in part by Ada-Europe