ENUM:
Factor documentation > Factor handbook > C library interface > Passing data between Factor and C > Enumeration types
Next:define-enum ( word base-type members -- )


Vocabulary
alien.syntax

Syntax
ENUM: type words... ; ENUM: type < base-type words...


Inputs and outputs
typea name to typedef to int or f
wordsa sequence of word names


Word description
Creates a c-type that boxes and unboxes integer values to symbols. A symbol is defined for each member word. The base c-type can optionally be specified and defaults to int. A constructor word <type> is defined for converting from integers to singletons. The generic word enum>number converts from singletons to integers. Enum-typed values are automatically prettyprinted as their singleton words. Unrecognizing enum numbers are kept as numbers.

Examples
Here is an example enumeration definition:
ENUM: color_t red { green 3 } blue ;

The following expression returns true:
3 <color_t> [ green = ] [ enum>number 3 = ] bi and


See also
define-enum, enum>number, number>enum

Definition
USING: alien.enums alien.parser ;

IN: alien.syntax

SYNTAX: ENUM: parse-enum (define-enum) ;