Chapter 5:Semantic Analysis

Type constructors .

Records : it applies to a tuple formed from field names and field types. Consider the declaration

type row = record

addr : integer;

lexeme : array [1 .. 15] of char

end;

var table: array [1 .. 10] of row;

The type row has type expression

record ((addr x integer) x (lexeme x array(1 .. 15, char)))

and type expression of table is array(1 .. 10, row)

Records :

A record type constructor is applied to a tuple formed from field names and field types. For example, the declaration

type row = record

addr: integer;

lexeme: array[1 .. 15] of char

end;

declares the type name row representing the type expression

record ((address X integer ) X (lexeme X array (1..15, char )))

Note: Including the field names in the type expression allows us to define another record type with the same fields but with different names without being forced to equate the two.