Enumerated types


Enumerated types define a finite group of ordered values. Each of these ordered values is associated with an identifier (an enumerated constant). Enumerated constants are ordered by the sequence in which they are defined, and they have consecutive ordinal numbers starting at zero. The built-in function ord can be used to retrieve the ordinal number of an enumerated constant.


Here are some examples of enumerated types

   (red, blue, green)
   (low, medium, high)
   (married, divorced, widowed, single)

In the examples above the first enumerated constant in each type (i.e. red, low, and married) have ordinal values of zero. The second enumerated constant in each type (i.e. blue, medium, and divorced) have ordinal values of one. The third enumerated constant in each type have ordinal values of two. And the fourth enumerated constant in the last type has ordinal value 3.


The syntax for enumerated types is given below:

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

   enumerated-type = '(' enumerated-constant-list ')'

   enumerated-constant = identifier

   enumerated-constant-list = enumerated-constant { ',' enumerated-constant }