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


3.2.1 Type Declarations

  1. A type_declaration declares a type and its first subtype.

    Syntax

  2. type_declaration ::=
         full_type_declaration
       | incomplete_type_declaration
       | private_type_declaration
       | private_extension_declaration
    
  3. full_type_declaration ::=
         type defining_identifier [known_discriminant_part]
           is type_definition;
       | task_type_declaration
       | protected_type_declaration
    
  4. type_definition ::=
         enumeration_type_definition | integer_type_definition
       | real_type_definition        | array_type_definition
       | record_type_definition      | access_type_definition
       | derived_type_definition
    

    Legality Rules

  5. A given type shall not have a subcomponent whose type is the given type itself.

    Static Semantics

  6. The defining_identifier of a type_declaration denotes the first subtype of the type. The known_discriminant_part, if any, defines the discriminants of the type See section 3.7 Discriminants. The remainder of the type_ declaration defines the remaining characteristics of (the view of) the type.
  7. A type defined by a type_declaration is a named type; such a type has one or more nameable subtypes. Certain other forms of declaration also include type definitions as part of the declaration for an object (including a parameter or a discriminant). The type defined by such a declaration is anonymous -- it has no nameable subtypes. For explanatory purposes, this International Standard sometimes refers to an anonymous type by a pseudo-name, written in italics, and uses such pseudo-names at places where the syntax normally requires an identifier. For a named type whose first subtype is T, this International Standard sometimes refers to the type of T as simply "the type T."
  8. A named type that is declared by a full_type_declaration, or an anonymous type that is defined as part of declaring an object of the type, is called a full type. The type_definition, task_definition, protected_definition, or access_definition that defines a full type is called a full type definition. Types declared by other forms of type_declaration are not separate types; they are partial or incomplete views of some full type.
  9. The definition of a type implicitly declares certain predefined operators that operate on the type, according to what classes the type belongs, as specified in See section 4.5 Operators and Expression Evaluation.
  10. The predefined types (for example the types Boolean, Wide_Character, Integer, root_integer, and universal_integer) are the types that are defined in a predefined library package called Standard; this package also includes the (implicit) declarations of their predefined operators. The package Standard is described in See section A.1 The Package Standard.

    Dynamic Semantics

  11. The elaboration of a full_type_declaration consists of the elaboration of the full type definition. Each elaboration of a full type definition creates a distinct type and its first subtype.

    Examples

  12. Examples of type definitions:
  13. (White, Red, Yellow, Green, Blue, Brown, Black)
    range 1 .. 72
    array(1 .. 10) of Integer
    
  14. Examples of type declarations:
  15. type Color  is (White, Red, Yellow, Green, Blue, Brown, Black);
    type Column is range 1 .. 72;
    type Table  is array(1 .. 10) of Integer;
    

    NOTES

  16. (3) Each of the above examples declares a named type. The identifier given denotes the first subtype of the type. Other named subtypes of the type can be declared with subtype_declarations See section 3.2.2 Subtype Declarations. Although names do not directly denote types, a phrase like "the type Column" is sometimes used in this International Standard to refer to the type of Column, where Column denotes the first subtype of the type. For an example of the definition of an anonymous type, see the declaration of the array Color_Table in See section 3.3.1 Object Declarations, its type is anonymous -- it has no nameable subtypes.


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