Contents | Prev | Next

5.8 Pointer types

Description

Pointer types define dynamic collections of values, each of which either identifies an instance of the pointer type's domain type or is the special value nil which is guaranteed not to identify any instance. Instances of a pointer type's domain type are called identified variables. The values of a pointer type's collection can be stored in variables, associated with the pointer type, called pointer variables. The act of using the value stored in a pointer variable to access the identified variable is called dereferencing the pointer variable. It is an error to deference a pointer variable which contains the special value nil.

A pointer variable can be passed to the built-in procedure new, which will create an identified variable of the same type as the pointer variable's domain type, and store the value identifying the identified variable in the pointer variable. The value identifying the identified variable is also added to the collection of values defined by the pointer variables type. It is an error if an identified variable can not be created because there is not enough available memory.

A pointer variable can also be passed to the built-in procedure dispose, which will destroy the identified variable identified by the value stored in the pointer variable. The value stored in the pointer variable is also removed from the collection of values defined by the pointer variable's type. It is an error to use dispose on a pointer variable containing the special value nil, or containing a value that is not in the collection of values defined by the pointer variable's type.

Example

Here are some examples of pointer types:

   ^integer
   ^real

Syntax

The syntax for defining new pointer types is given below:

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

   new-pointer-type = '^' domain-type | '@' domain-type

   domain-type = type-identifier

Contents | Prev | Next