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


4.3.1 Record Aggregates

  1. In a record_aggregate, a value is specified for each component of the record or record extension value, using either a named or a positional association.

    Syntax

  2. record_aggregate ::= (record_component_association_list)
    
  3. record_component_association_list ::=
         record_component_association {, record_component_association}
       | null record
    
  4. record_component_association ::=
       [ component_choice_list => ] expression
    
  5. component_choice_list ::=
         component_selector_name {| component_selector_name}
       | others
    
    1. A record_component_association is a named component association if it has a component_choice_list; otherwise, it is a positional component association. Any positional component associations shall precede any named component associations. If there is a named association with a component_choice_list of others, it shall come last.
    2. In the record_component_association_list for a record_aggregate, if there is only one association, it shall be a named association.

Name Resolution Rules

  1. The expected type for a record_aggregate shall be a single nonlimited record type or record extension.
  2. For the record_component_association_list of a record_aggregate, all components of the composite value defined by the aggregate are needed; for the association list of an extension_aggregate, only those components not determined by the ancestor expression or subtype are needed, See section 4.3.2 Extension Aggregates. Each selector_name in a record_component_association shall denote a needed component (including possibly a discriminant).
  3. The expected type for the expression of a record_component_association is the type of the associated component(s); the associated component(s) are as follows:
    1. For a positional association, the component (including possibly a discriminant) in the corresponding relative position (in the declarative region of the type), counting only the needed components;
    2. For a named association with one or more component_selector_names, the named component(s);
    3. For a named association with the reserved word others, all needed components that are not associated with some previous association.

Legality Rules

  1. If the type of a record_aggregate is a record extension, then it shall be a descendant of a record type, through one or more record extensions (and no private extensions).
  2. If there are no components needed in a given record_component_association_list, then the reserved words null record shall appear rather than a list of record_component_associations.
  3. Each record_component_association shall have at least one associated component, and each needed component shall be associated with exactly one record_component_association. If a record_component_association has two or more associated components, all of them shall be of the same type.
  4. If the components of a variant_part are needed, then the value of a discriminant that governs the variant_part shall be given by a static expression.

    Dynamic Semantics

  5. The evaluation of a record_aggregate consists of the evaluation of the record_component_association_list.
  6. For the evaluation of a record_component_association_list, any per-object constraints, See section 3.8 Record Types, for components specified in the association list are elaborated and any expressions are evaluated and converted to the subtype of the associated component. Any constraint elaborations and expression evaluations (and conversions) occur in an arbitrary order, except that the expression for a discriminant is evaluated (and converted) prior to the elaboration of any per-object constraint that depends on it, which in turn occurs prior to the evaluation and conversion of the expression for the component with the per-object constraint.
  7. The expression of a record_component_association is evaluated (and converted) once for each associated component.

    NOTES

  8. (7) For a record_aggregate with positional associations, expressions specifying discriminant values appear first since the known_discriminant_part is given first in the declaration of the type; they have to be in the same order as in the known_discriminant_part.

    Examples

  9. Example of a record aggregate with positional associations:
  10. (4, July, 1776)  --  See section 3.8 Record Types
    
  11. Examples of record aggregates with named associations:
  12. (Day => 4, Month => July, Year => 1776)
    (Month => July, Day => 4, Year => 1776)
    
  13. (Disk, Closed, Track => 5, Cylinder => 12)  --  See section 3.8.1 Variant Parts and Discrete Choices
    (Unit => Disk, Status => Closed, Cylinder => 9, Track => 1)
    
  14. Example of component association with several choices:
  15. (Value => 0, Succ|Pred => new Cell'(0, null, null))
    --  See section 3.10.1 Incomplete Type Declarations
    
  16. --  The allocator is evaluated twice:
    --  Succ and Pred designate different cells
    
  17. Examples of record aggregates for tagged types, See section 3.9 Tagged Types and Type Extensions, and See section 3.9.1 Type Extensions
  18. Expression'(null record)
    Literal'(Value => 0.0)
    Painted_Point'(0.0, Pi/2.0, Paint => Red)
    


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