Contents | Prev | Next

5.2 Array types

Description

Array types define collections of values of the same type (called the array's component type) and associates an index type with each collections. Each member of an array's collection is called an array element and is identified by a value of the array's index type. The number of array elements in an array is fixed, and is equal to the number of values defined by the array's index type.

You can have arrays of arrays (i.e. an array's component type may itself be an array type). It is sometimes easier to think about arrays of arrays as multi-dimensional arrays (i.e. arrays defining a collection of values with an axis for each array component, where each element is identified by values from each component array's index type).

Irie Pascal supports fixed length strings as defined in Standard Pascal (i.e. fixed length strings, which are simply packed arrays of char, having a lower bound of one and an upper bound of two or greater). Fixed length strings have special properties in addition to the properties they share with other arrays. Fixed length strings, unlike other arrays, can be compared with the relational operators. Also fixed length strings, unlike other arrays, can be read from and written to text files as a unit using the built-in procedures read, readln, write, and writeln. NOTE: Irie Pascal also supports variable length string types.

NOTE: As a shorthand notation a multi-dimensional array type can be defined by listing the index types of each of the component arrays. In other words

    array[1..10, char, boolean] of integer

is a shorthand notation for

    array[1..10] of array[char] of array[boolean] of integer

Example

Here are some examples of array types:

    array[1..10] of real
    array[char] of boolean
    array[-456..-450] of array[boolean] of integer

Syntax

The syntax for array types is given below:

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

   array-type = 'array' [ index-type-list ']' 'of' component-type

   component-type = type-denoter

   domain-type = type-identifier

   index-type = ordinal-type

   index-type-list = index-type { ',' index-type }

   new-ordinal-type = enumerated-type | subrange-type

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

   new-structured-type =
      [ 'packed' ] array-type |
      [ 'packed' ] record-type |
      [ 'packed' ] set-type |
      [ 'packed' ] file-type |
      [ 'packed' ] list-type |
                         object-type |
                         string-type

   new-type = new-ordinal-type | new-structured-type | new-pointer-type

   ordinal-type = new-ordinal-type | ordinal-type-identifier

   ordinal-type-identifier = identifier

   type-denoter = type-identifier | new-type

   type-identifier = identifier

Contents | Prev | Next