modula-2 home

  Win32 API  


Type declarations

Type declarations create new named data types. The format for type declarations is:

   TYPE {Name = TypeSpecification;}

Name is the name of the new type.

TypeSpecification can be:

If the TypeSpecification is a type name, the new type is equivalent to the named type. Otherwise, a new type is created.


     Integer     = INTEGER;
     SmallInt    = [-10..10];
     Color       = (Red, Green, Blue);
     CharPointer = POINTER TO CHAR;
     ColorSet    = SET OF COLOR;
     String      = ARRAY [0..255] OF CHAR;
     Complex     = RECORD A,B : REAL; END;
     RealFunc    = PROCEDURE(REAL) : REAL;


  • Wirth N: Programming in Modula-2, 3rd ed. Springer Verlag, Berlin, 1985.
  • Stony Brook Modula-2 documentation. Used with permission. Note: Stony-Brook M2 offers an extended syntax with features not described here. Stony Brook M2 users are encouraged to visit the Stony Brook website and to consult the Stony Brook help system.