Enumerations allow you to specify a set of related values that have
no further structure, similar to enum
types in C. For example:
type color: enum { Red, White, Blue, };
defines the values Red
, White
, and Blue
. A variable
of type color
holds one of these values. Note that Red
et al
have global scope. You cannot define a variable or type
with those names. (Also note that, as usual, the comma after Blue
is optional.)
The only operations allowed on enumerations are comparisons for equality. Unlike C enuemrations, they do not have values or an ordering associated with them.
You can extend the set of values in an enumeration using
redef enum
identifier += {
name-list }
:
redef enum color += { Black, Yellow };