Node:Record Types, Next:, Previous:Array Types, Up:Type Definition Possibilities



Record Types

type
  record_type_identifier = record
    field_identifier: type_definition;
    ...
    field_identifier: type_definition;
  end;

or, with a variant part,

type
  record_type_identifier = record
    field_identifier: type_definition;
    ...
    field_identifier: type_definition;
  case bar: variant_type of
    selector: (field_declarations);
    selector: (field_declarations);
    ...
  end;

or, without a variant selector field,

type
  record_type_identifier = record
    field_identifier: type_definition;
    ...
    field_identifier: type_definition;
  case variant_type of
    selector: (field_declarations);
    selector: (field_declarations);
    ...
  end;

The reserved word record defines a structure of fields. Records can be packed to save memory usage at the expense of speed.

The reserved word record and record types are defined in ISO 7185 Pascal. According to ISO Pascal, the variant type must be an identifier. GNU Pascal, like UCSD and Borland Pascal, also allows a subrange here.

A record field is accessed by record_type_variable . field_identifier

See also: packed, case Statement.