Contents | Prev | Next | Index


Array Types

An array is a structure consisting of a number of elements that are all of the same type, called the element type or component type. The number of elements of an array type is called its length. The length is determined by the specification of an index type. The array type declaration specifies both the component type and the index type. The latter must be an enumeration, a subrange type, or one of the non-real basic types. The elements of the array are designated by indices, values belonging to the index type.

array_type      ::= ARRAY index_type_list OF type
index_type_list ::= index_type_list , index_type
                ::= index_type
index_type      ::= simple_type

A type of the form:

  ARRAY T0,T1,...Tn OF T

is understood as an abbreviation of

  ARRAY T0 OF
    ARRAY T1 OF
    ...
      ARRAY Tn OF T

Modula-2 also allows arrays without the index specifier. These are called open arrays. They are restricted to base types of pointer types, to element types of open arrays, and to formal parameter types. If they are used for multidimensional open arrays or for pointer types, the language extensions must be enabled via a compiler switch or directive.

formal_type  ::= qualident
             ::= open_array qualident
pointer_type ::= POINTER TO type
             ::= POINTER TO open_array qualident
open_array   ::= open_array ARRAY OF
             ::= ARRAY OF 


Contents | Prev | Next | Index

Canterbury Modula-2 for Java  (Last documentation update Feb 8, 2000)
Copyright © 1998 Mill Hill & Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to mhc@webcom.com