Go to the first, previous, next, last section, table of contents.


12.5.1 Formal Private and Derived Types

  1. The class determined for a formal private type can be either limited or nonlimited, and either tagged or untagged; no more specific class is known for such a type. The class determined for a formal derived type is the derivation class rooted at the ancestor type.

    Syntax

  2. formal_private_type_definition ::=
       [[abstract] tagged] [limited] private
    
  3. formal_derived_type_definition ::=
       [abstract] new subtype_mark [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. 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, the optional reserved word abstract shall appear only if the ancestor type is a 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:
    1. If the ancestor subtype is constrained, the actual subtype shall be constrained, and shall be statically compatible with the ancestor;
    2. If the ancestor subtype is an unconstrained access or composite subtype, the actual subtype shall be unconstrained.
    3. If the ancestor subtype is an unconstrained discriminated subtype, then the actual shall have the same number of discriminants, and each discriminant of the actual shall correspond to a discriminant of the ancestor, in the sense of See section 3.7 Discriminants.

  1. 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:
    1. The actual type shall be a type with the same number of discriminants.
    2. The actual subtype shall be unconstrained.
    3. The subtype of each discriminant of the actual type shall statically match the subtype of the corresponding discriminant of the formal type.

  1. 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

  2. The class determined for a formal private type is as follows:
  3. Type Definition         Determined Class
    
    limited private         the class of all types
    private                 the class of all nonlimited types
    tagged limited private  the class of all tagged types
    tagged private          the class of all nonlimited tagged types
    
  4. The presence of the reserved word abstract determines whether the actual type may be abstract.
  5. 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.
  6. 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 section 3.4 Derived Types and Classes.
  7. For a formal derived type, the predefined operators and inherited user-defined subprograms are determined by the ancestor type, and are implicitly declared at the earliest place, if any, within the immediate scope of the formal type, where the corresponding primitive subprogram of the ancestor is visible, See section 7.3.1 Private Operations. In an instance, the copy of such an implicit declaration declares a view of the corresponding primitive subprogram of the ancestor, even if this primitive has been overridden for the actual type. 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.
  8. For a prefix S that denotes a formal indefinite subtype, the following attribute is defined:
  9. 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.
    

    NOTES

  10. (9) In accordance with the general rule that the actual type shall belong to the class determined for the formal, See section 12.5 Formal Types.:
    1. If the formal type is nonlimited, then so shall be the actual;
    2. For a formal derived type, the actual shall be in the class rooted at the ancestor subtype.

  1. (10) The actual type can be abstract only if the formal type is abstract, See section 3.9.3 Abstract Types and Subprograms.
  2. (11) If the formal has a discriminant_part, the actual can be either definite or indefinite. Otherwise, the actual has to be definite.


Go to the first, previous, next, last section, table of contents.