Defining Enumerations
Somewhere a queen is weeping...
Somewhere a king has no wife.
- Jimi Hendrix
The Enumeration Definition statement defines a new enumeration data type. An enumeration is a primitive data type which contains one or more discrete values, with each value defined as a unique keyword within the list. The following table shows the syntax for the enumeration statement.
♦ The following keywords are supported by the enumeration statement.
♦ Defines a new enumeration data type which contains one or more discrete values that an enumeration variable can have. The list of allowable values is entered within the braces, and each value must conform to standard Aztec identifier naming rules. The enumeration value list can contain any number of discrete values, but there must be at least one value.
♦ An individual enumeration value is accessed using “EnumName.EnumValue1”.
♦ If the “expose” keyword is used, an individual enumeration value can be accessed using only the name of the value. In this case, each enumeration value name must be unique among all Aztec keywords, data types (class, enum, type) and global variables which are visible based on the default space list.
♦ If "expose" is not used, the name only needs to be unique within the enumeration value list.
♦ When a new enumeration class is created, the system automatically creates a set of instance, global and compiler methods to operate on that enumeration. A set of class constants specific to the new enumeration is created as well.
♦ Every new enumeration is a primitive data type which is derived directly from 'Base'. The following hierarchy map shows "Enumeration" as its base class in italics to reflect the automatic method and constant creation, but there is no actual class named "Enumeration".
♦ The ‘bool’ data type is an example of an enumeration with the “expose” keyword (with values ‘true’ and ‘false’). The individual values can be accessed using just “false” and “true”, but can also be accessed using “bool.false” and “bool.true”.