Ada Resource Association
News and resources for the Ada programming language
Ada Reference ManualLegal Information
Contents   Index   References   Search   Previous   Next 

12.5.1 Formal Private and Derived Types

1/2
In its most general form, the category determined for a formal private type is all types, but it can be restricted to only nonlimited types or to only tagged types. The category determined for a formal derived type is the derivation class rooted at the ancestor type. 

Syntax

2
formal_private_type_definition ::= [[abstracttagged] [limitedprivate
3/2
formal_derived_type_definition ::= 
     [abstract] [limited | synchronizednew subtype_mark [[and interface_list]with private]

Legality Rules

4
If a generic formal type declaration has a known_discriminant_part, then it shall not include a default_expression for a discriminant. 
5/2
The ancestor subtype of a formal derived type is the subtype denoted by the subtype_mark of the formal_derived_type_definition. For a formal derived type declaration, the reserved words with private shall appear if and only if the ancestor type is a tagged type; in this case the formal derived type is a private extension of the ancestor type and the ancestor shall not be a class-wide type. Similarly, an interface_list or the optional reserved words abstract or synchronized shall appear only if the ancestor type is a tagged type. The reserved word limited or synchronized shall appear only if the ancestor type and any progenitor types are limited types. The reserved word synchronized shall appear (rather than limited) if the ancestor type or any of the progenitor types are synchronized interfaces.
5.1/2
  The actual type for a formal derived type shall be a descendant of the ancestor type and every progenitor of the formal type. If the reserved word synchronized appears in the declaration of the formal derived type, the actual type shall be a synchronized tagged type. 
6
If the formal subtype is definite, then the actual subtype shall also be definite. 
7
For a generic formal derived type with no discriminant_part:
8
9
10
10.1/2
11
The declaration of a formal derived type shall not have a known_discriminant_part. For a generic formal private type with a known_discriminant_part:
12
13
14
15
For a generic formal type with an unknown_discriminant_part, the actual may, but need not, have discriminants, and may be definite or indefinite.

Static Semantics

16/2
 The category determined for a formal private type is as follows: 
17/2
Type Definition  Determined Category

limited private  the category of all types
private  the category of all nonlimited types
tagged limited private  the category of all tagged types
tagged private  the category of all nonlimited tagged types
18
The presence of the reserved word abstract determines whether the actual type may be abstract.
19
A formal private or derived type is a private or derived type, respectively. A formal derived tagged type is a private extension. A formal private or derived type is abstract if the reserved word abstract appears in its declaration.
20/2
 If the ancestor type is a composite type that is not an array type, the formal type inherits components from the ancestor type (including discriminants if a new discriminant_part is not specified), as for a derived type defined by a derived_type_definition (see 3.4 and 7.3.1).
21/2
 For a formal derived type, the predefined operators and inherited user-defined subprograms are determined by the ancestor type and any progenitor types, and are implicitly declared at the earliest place, if any, immediately within the declarative region in which the formal type is declared, where the corresponding primitive subprogram of the ancestor or progenitor is visible (see 7.3.1). In an instance, the copy of such an implicit declaration declares a view of the corresponding primitive subprogram of the ancestor or progenitor of the formal derived type, even if this primitive has been overridden for the actual type. When the ancestor or progenitor of the formal derived type is itself a formal type, the copy of the implicit declaration declares a view of the corresponding copied operation of the ancestor or progenitor. In the case of a formal private extension, however, the tag of the formal type is that of the actual type, so if the tag in a call is statically determined to be that of the formal type, the body executed will be that corresponding to the actual type. 
22/1
 For a prefix S that denotes a formal indefinite subtype, the following attribute is defined: 
23
S'Definite
S'Definite yields True if the actual subtype corresponding to S is definite; otherwise it yields False. The value of this attribute is of the predefined type Boolean. 

Dynamic Semantics

23.1/2
   In the case where a formal type is tagged with unknown discriminants, and the actual type is a class-wide type T'Class:
23.2/2
23.3/2
NOTES
24/2
9  In accordance with the general rule that the actual type shall belong to the category determined for the formal (see 12.5, “Formal Types”): 
25
26
27
10  The actual type can be abstract only if the formal type is abstract (see 3.9.3).
28
11  If the formal has a discriminant_part, the actual can be either definite or indefinite. Otherwise, the actual has to be definite. 

Contents   Index   References   Search   Previous   Next 
Ada-Europe Sponsored by Ada-Europe