Super Prev Next

Variable declarations

Variable declarations introduce variables by defining an identifier and a data type for them.

  VariableDeclaration = IdentList ":" Type.

Record and pointer variables have both a static type (the type with which they are declared - simply called their type) and a dynamic type (the type they assume at run time). For pointers and variable parameters of record type the dynamic type may be an extension of their static type. The static type determines which fields of a record are accessible. The dynamic type is used to call type-bound procedures (see Type-bound procedures).

Examples of variable declarations (refer to examples in Type declarations):

  i, j, k: INTEGER
  x, y: REAL
  p, q: BOOLEAN
  s: SET
  F: Function
  a: ARRAY 100 OF REAL
       name  : ARRAY 32 OF CHAR;
       ccount: INTEGER
  t, c: Tree