Chapter 7 Data Types

7.1 Type systems

7.1 Type systems

7.1 Type systems and subroutines

7.1.1 Type checking

7.1.1 Type checking

7.1.2 Polymorphism (revisited from page 148)

7.1.3 The meaning of "type"

7.1.3 Three ways to think about types

7.1.4 Classification of types

7.1.4 Enumeration types

type weekday = (sun, mon, tue, wed, thue, fri, sat);
for today := mon to fri do begin ...
var daily_attendance : array [weekday] of integer;


enum weekday {sun, mon, tue, wed, thu, fri, sat};
int main()

  enum weekday day1 = sun;
  enum weekday day2 = mon;
  enum weekday day3;
  day3 = day1 + day2;

7.1.4 Subranges

7.1.4 Composite types

7.2.1 Type equivalence

7.2.1 Type conversions and casts

7.2.2 Type compatibility


7.2.3 Type inference

type Atype = 0..20;
type Btype = 10..30;

var a: Atype;
var b: Btype;

What about indexing?

7.3 Records/Structures and Variants/Unions

Simplifying the syntax

with complex.complicated.deep.stuff do

  fieldx := 'STUFF GOES HERE';
  fieldy := 'STUFF GOES THERE';


7.4 Arrays

Array declarations


Conformant arrays

Dynamic arrays

Memory layout



Pointers and recursive types

Pointers and models

Pointers and value models

Note on page 353 relating to "stack smashing":

C allows conflation of pointer arithmetic with array access

Garbage collection

Garbage collection

Garbage collection

Garbage collection

Garbage collection

7.8 Lists

7.8 Lists

7.10 Equality and assignment

Equality and assignment

7.11 Wrapping up

7.11 Wrapping up

7.11 Wrapping up