On this page:
_ enum
_ bitmask
Version: 4.1

3.8 Enumerations and Masks

Although the constructors below are describes as procedures,they are implemented as syntax, so that error messages can report a type name where the syntactic context implies one.

(_enum symbols [basetype])  ctype?

  symbols : list?

  basetype : ctype? = _ufixint

Takes a list of symbols and generates an enumeration type. The enumeration maps between the given symbols and integers, counting from 0.

The list symbols can also set the values of symbols by putting '= and an exact integer after the symbol. For example, the list '(x y = 10 z) maps 'x to 0, 'y to 10, and 'z to 11.

The basetype argument specifies the base type to use.

(_bitmask symbols [basetype])  ctype?

  symbols : (or symbol? list?)

  basetype : ctype? = _uint

Similar to _enum, but the resulting mapping translates a list of symbols to a number and back, using bitwise-or. A single symbol is equivalent to a list containing just the symbol. The default basetype is _uint, since high bits are often used for flags.