List types


As an extension to Standard Pascal, Irie Pascal supports list types. List types define ordered collections of values of a single type (called the list's component type). Each value in a list type's collection is identified by its position in the collection. Unlike file types the values in a list type's collection are NOT persistent (i.e. they are not stored when your program is not running).

The size of the collection of values defined by a list type (i.e. the number of values in the collection) is potentially unlimited. List types do not impose any limit on the size of their collections. In practice the maximum size of a list type's collection is determined by the amount of memory available to your program.


Here are some examples of list types

   list of integer;
   list of char;

Below is a simple example program that uses a list to store and sort random integer values.

program listexample(output);
   l : list of integer;
   i : integer;

   procedure SortList;
      i, temp : integer;
      swapped : boolean;
      //Bubble sort the list
         swapped := false;
         for i := 1 to length(l)-1 do
               if l[i] > l[i+1] then
                     temp := l[i];
                     l[i] := l[i+1];
                     l[i+1] := temp;
                     swapped := true;
      until not swapped;

   randomize;  //initialize random number generator
   //Insert 100 random integer values into the list
   for i := 1 to 100 do
      insert(random(1000), l);
   //Sort the values in the list
   //Output the values in the list
   for i := 1 to length(l) do


The syntax for defining new list types is given below:

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

   list-type = 'list' 'of' component-type

   component-type = type-denoter

   domain-type = type-identifier

   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 |

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

   type-denoter = type-identifier | new-type

   type-identifier = identifier