Next: subint
, Previous: bool
, Up: Types and Expressions [Contents][Index]
enum
An interface or component can specify a user defined enumerated type. Such a type has a name and a list of values.
enum ::= "enum" identifier "{" fields "}" ";" fields ::= identifier ("," identifier)* ","?
An example:
enum result {FALSE,TRUE,ERROR};
where enum
is a keyword; this defines the enum type result
with three values.
In expressions the enum values are referred to with a dot notation:
result.FALSE
.
Available enum operators are:
e1 == e2
Equality of two enum expressions,
e1 != e2
Inequality of two enum expressions,
v.ERROR
A field-test: testing the value of an enum variable, denoted by
v.ERROR
, which is shorthand for v == result.ERROR
where e1
and e2
denote enum expressions, and v
an
enum variable of type result
.