modula-2 home

  Home  
  Tutorial  
  Win32 API  
  Reference  
  Projects  
 

 

Type declarations

Enumerations

An enumeration is a list of identifiers that denote the values which constitute a data type. These identifiers are used as constants in the program. They, and no other values, belong to this type. The values are ordered, and the ordering relation is defined by their sequence in the enumeration. The ordinal number of the first value is 0.

   enumeration = "(" IdentList ")".
   IdentList = ident {" ," ident}.

Examples of enumerations:

   (red, green, blue)
   (club, diamond, heart, spade)
   (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday)


Source:

  • Wirth N: Programming in Modula-2, 3rd ed. Springer Verlag, Berlin, 1985.