Record variables


Record variables are used to store values of record types (i.e. collections of values of possibly different types). Each member of a record type's collection is called a field, and is usually identified by a name (i.e. the field name). Fields names have the same syntax as identifiers, and no two fields in a record type can have the same name. Every field in a record must have a name, except for the variant selector of a variant record for which a name is optional.

A reference to a record variable is a reference to the entire record as a unit, and can be used to both store record values into, and retreive record values from the record variable.

Each field in a record is stored in a seperate component of the record, and can be referenced individually, in order to store values into, and retrieve values from specific fields. A reference to an individual field in a record is called a field designator. Field designators usually consist of a reference to the record variable followed by a period (.), and then finally followed by a field specifier (which is what the name of the field is called when used in this way). Within the statement part of a with statement, field designators can consist of just a field designator identifier (which is what the name of the field is called when used in this way). The record variable is referenced once in the record variable list part of the with statement. This can be useful when the statement part of a with statement contains many references to the fields of a record.


The syntax for field designators is given below:

(NOTE: for clarity some parts of the syntax are omitted, see Irie Pascal Grammar for the full syntax):

   field-designator = record-variable '.' field-specifier | field-designator-identifier

   field-designator-identifier = identifier

   field-identifier = identifier

   field-specifier = field-identifier

   record-variable = variable-access

where record-variable is a reference to a record variable, and field-specifier and field-designator-identifier are field names. NOTE: field-designator-identifier can be used only in the statement part of a with statement.