In computer programming, an enumerated typea is a data type consisting of a set of named values called elements, members, enumeral, or enumerators of the type. The enumerator names are usually identifiers that behave as constants in the language. An enumerated type can be seen as a degenerate tagged union of unit type. A variable that has been declared as having an enumerated type can be assigned any of the enumerators as a value. In other words, an enumerated type defines a set of discrete, mutually exclusive constants that are not generallyb written to a concrete representation in the computer's memory; compilers and can represent them arbitrarily without specification from the programmer. Cite error: There are tags or templates on this page, but the references will not show without a template or template (see the help page).
Where Enumerated type leads. Every connection below has a source: a link in this article, a shared Wikipedia category, or CirrusSearch text similarity. Articles already on your trail are left out.
In computer programming, an enumerated type is a data type consisting of a set of named values called elements, members, enumeral, or enumerators of the type.
If a value (termed a raw value) is explicitly provided for each enumeration case, the value can be a string, a character, or any integer or floating-point.
Terms the article defines in bold, quoted in context.
Categories:
Data types
Type theory
3,305 words · 20 references · revision 1375672046 · CC BY-SA 4.0
For example, the four suits in a deck of playing cards could be represented in an enum called CardSuit, containing four members named CLUBS, DIAMONDS, SPADES, and HEARTS. If a variable v is declared having CardSuit as its data type, one must assign one of those four values to it.c
Although the enumerators are usually distinct, some languages may allow the same enumerator to be listed twice in the type's declaration. The names of enumerators are arbitrary and are up to the programmer; an enum named Color could contain the enumerators RED, GREEN, ZEBRA, MISSING, and BACON. In some languages, the declaration of an enumerated type also intentionally defines the total order of its members (e.g., HIGH, MEDIUM and LOW priorities); in others, the enumerators are unordered by default (e.g., ENGLISH, FRENCH, GERMAN and SPANISH supported languages); in others still, an implicit ordering arises from how the compiler chooses to internally represent the enumerators.
Some enumerator types may be built into the language. For example, the Boolean type is often a pre-defined enumeration of the two values false and true. A unit type consisting of a single value may also be defined to represent null. Many languages allow users to define new enumerated types.
Values and variables of an enumerated type are usually implemented with some integer type as the underlying representation. Some languages, especially system programming languages, allow the user to specify the bit combination to be used for each enumerator, which can be useful to efficiently represent sets of enumerators as fixed-length bit strings. In type theory, enumerated types are often regarded as tagged unions of unit types. Since such types are of the form , they may also be written as natural numbers.
Rationale
Some early programming languages did not originally have enumerated types. If a programmer wanted a variable, for example myColor, to have a value of RED, the constant RED would be declared and assigned some arbitrary value, usually an integer constant. The constant RED would then be assigned to myColor. Other techniques assigned arbitrary values to strings containing the names of the enumerators.
These arbitrary values were sometimes referred to as magic numbers since there often was no explanation as to how the numbers were obtained or whether their actual values were significant. These magic numbers could make the source code harder for others to understand and maintain.
Enumerated types, on the other hand, make the code more self-documenting. Depending on the language, the compiler could automatically assign default values to the enumerators, thereby hiding unnecessary detail from the programmer. These values may not even be visible to the programmer (see information hiding). Enumerated types can also prevent a programmer from writing illogical code such as performing mathematical operations on the values of the enumerators. If the value of a variable that was assigned an enumerator were to be printed, some programming languages could also print the name of the enumerator rather than its underlying numerical value. A further advantage is that enumerated types can allow compilers to enforce semantic correctness: myColor = TRIANGLE can be forbidden, while myColor = RED should be accepted, even if TRIANGLE and RED are both internally represented with the value 1.
Conceptually, an enumerated type is similar to a list of nominals (numeric codes), since each possible value of the type is assigned a distinctive natural number. A given enumerated type is thus a concrete implementation of this notion. When order is meaningful and/or used for comparison, then an enumerated type becomes an ordinal type.
While ALGOL 60 itself has no enumeration type, several languages descended from it do. In particular, Pascal had a strong influence on the design of Ada.
Pascal
In Pascal, an enumerated type can be implicitly declared by listing the values in a parenthesised list:
var
suit: (clubs, diamonds, hearts, spades);
The declaration will often appear in a type synonym declaration, such that it can be used for multiple variables:
type
cardsuit = (clubs, diamonds, hearts, spades);
card = record
suit: cardsuit;
value: 1 .. 13;
end;
var
hand: array [ 1 .. 13 ] of card;
trump: cardsuit;
The order in which the enumeration values are given matters. An enumerated type is an ordinal type, and the pred and succ functions will give the prior or next value of the enumeration, and ord can convert enumeration values to their integer representation. Standard Pascal does not offer a conversion from arithmetic types to enumerations, however. Extended Pascal offers this functionality via an extended succ function. Some other Pascal dialects allow it via type-casts. Some modern descendants of Pascal, such as Modula-3, provide a special conversion syntax using a method called VAL; Modula-3 also treats BOOLEAN and CHAR as special pre-defined enumerated types and uses ORD and VAL for standard ASCII decoding and encoding.
Pascal style languages also allow enumeration to be used as array index:
var
suitcount: array [cardsuit] of integer;
Ada
In Ada, the definition of enumerated types is similar to Pascal, replacing the use of "=" with "is":
datatype cardsuit = Clubs | Diamonds | Hearts | Spades
type card = { suit: cardsuit; value: int }
val hand : card list
val trump : cardsuit
In these languages, the integer representation is completely hidden from the programmer, if the language employs it. However, Haskell has the Enumtype class, which a type can derive or implement to get a mapping between the type and Int.
Databases
Some databases support enumerated types directly. MySQL provides an enumerated type ENUM with allowable values specified as strings when a table is created. The values are stored as numeric indices with the empty string stored as 0, the first string value stored as 1, the second string value stored as 2, etc. Values can be stored and retrieved as numeric indexes or string values.16
aAlso called enumeration, enum, or factor in R, a condition-name in COBOL, a status variable in the JOVIAL, an ordinal in PL/I, or a categorical variable in statistics.
bIn some languages explicit values are allowed, and in a few they are even required.
cIn COBOL, a variable of any type can serve as an enumeration if it is followed by condition-name (88-level) definitions.
type Cardsuit is (clubs, diamonds, hearts, spades);
In addition to Pred, Succ, Val and Pos, Ada also supports simple string conversions via Image and Value.
Similar to C-style languages, Ada allows the internal representation of the enumeration to be specified:
for Cardsuit use
(clubs => 1, diamonds => 2, hearts => 4, spades => 8);
Ada also allows the number of bits of the enumeration to be specified in a straightforward manner, unlike C-style languages which have inconsistent support often leading to subtle miscompilation errors:1
for Cardsuit'Size use 4; -- 4 bits
Additionally, one can use enumerations as indexes for arrays, like in Pascal, but there are attributes defined for enumerations:
Shuffle : constant array(Cardsuit) of Cardsuit :=
(Clubs => Cardsuit'Succ(Clubs), -- see attributes of enumerations 'First, 'Last, 'Succ, 'Pred
Diamonds => Hearts, --an explicit value
Hearts => Cardsuit'Last, --first enumeration value of type Cardsuit e.g., clubs
Spades => Cardsuit'First --last enumeration value of type Cardsuit e.g., spades
);
Like Modula-3, Ada treats Boolean and Character as special pre-defined (in package "Standard") enumerated types. Unlike Modula-3 one can also define own character types:
type Cards is ('7', '8', '9', 'X', 'J', 'Q', 'K', 'A');
PL/I
Neither the original PL/I nor ANSI ANSI X3.53–1976 has enumerations, but the IBM Enterprise PL/I2 has ordinal types.
An ordinal variable cannot be used directly as a subscript or as a DO TO limit. However,
The type functions first and last, and the builtin functions binaryvalue, ordinalpred and ordinalsucc, allow it indirectly.
DO UPTHRU and DO DOWNTO support ordinals.
define ordinal foo (green,with,envy);
declare ix ordinal foo,
bar(first(:foo:):last(:foo:)) fixed bin;
do i = first(:foo:) to last(:foo:);
bar(i)=13;
end;
do ix=first(:foo:) upthru last(:foo:);
i = binaryvalue(ix);
bar(i) = bar(i) + 1;
end;
do ix=first(:foo:) repeat ordinalsucc(ix) until (ix=first(:foo:)) /* stop on wrap around. */;
i = binaryvalue(ix);
display (bar(i) || ' at ' || ix);
end;
C-family languages
C
The original K&R dialect of the programming language C had no enumerated types.3 In C, enumerations are created by explicit definitions (the enum keyword by itself does not cause allocation of storage) which use the enum keyword and are reminiscent of struct and union definitions:
C exposes the integer representation of enumeration values directly to the programmer. Integers and enum values can be mixed freely, and all arithmetic operations on enum values are permitted. It is even possible for an enum variable to hold an integer that does not represent any of the enumeration values. In fact, according to the language specification, the above code will define CLUBS, DIAMONDS, HEARTS, and SPADES as constants of type int, which will only be converted (silently) to enum CardSuit if they are stored in a variable of that type.
C also allows the programmer to choose the values of the enumeration constants explicitly, even without type. The following could be used to define a type that allows mathematical sets of suits to be represented as an enum CardSuit via bitwise logic operations, by representing each suit as a power of two:
Since C23, the underlying type of an enumeration can be specified by the programmer, with the same syntax as C++.4 This allows programmers to make optimized enums by choosing a more suitable underlying type.
Enums in C are not scoped or qualified, because C lacks namespacing features. Prior to the introduction of the constexpr keyword in C23, enums were often used to declare compile-time, type-safe constants without use of the C preprocessor:
Enumerated types in the C# programming language preserve most of the "small integer" semantics of C's enums. In C#, all enums are classes which extend System.Enum.5 Some arithmetic operations are not defined for enums, but an enum value can be explicitly converted to an integer (and vice-versa), and an enum variable can have values that were not declared by the enum definition. For example, in the below code:
the expressions CardSuit.Diamonds + 1 and CardSuit.Hearts - CardSuit.Clubs are allowed directly (as it may make sense to step through the sequence of values or ask how many steps there are between two values), but CardSuit.Hearts * CardSuit.Spades is deemed to make less sense and is only allowed if the values are first explicitly converted to integers.
C# also provides the C-like feature of being able to define specific integer values for enumerations. Through this, it is possible to perform binary operations on enumerations, thus treating enumeration values as sets of flags. These flags can be tested using binary operations or with the enum type's builtin HasFlag() method.6
The enumeration definition defines names for the selected integer values and is syntactic sugar, as it is possible to assign to an enum variable other integer values that are not in the scope of the enum definition.789
C++
C++ has enumeration types that are directly inherited from C's and work mostly like these, except that an enumeration is a real type in C++, giving added compile-time checking. As with structs, the C++ enum keyword is combined with a typedef, so instead of referring to the type as enum MyEnum, one can simply refer to it as MyEnum. This can be simulated in C using a typedef: typedef enum { VALUE_1, VALUE_2 } MyEnum;
C++11 also provides a second kind of enumeration, called a scoped enumeration. These are type-safe: the enumerators are not implicitly converted to an integer type. Among other things, this allows I/O streaming to be defined for the enumeration type. Another feature of scoped enumerations is that the enumerators must be qualified by the enum name, so usage requires prefixing with the name of the enumeration (e.g., Color::RED for the first enumerator in the example below), unless a using enum declaration (introduced in C++20) has been used to bring the enumerators into the current scope. A scoped enumeration is specified by the keywords enum class (or enum struct, they are identical).10 For example:
// C-style unscoped enum
enum CardSuit {
CLUBS,
DIAMONDS,
SPADES,
HEARTS,
};
// C++11-style scoped enum
enum class Color {
RED,
GREEN,
BLUE,
};
// C++11-style scoped enum
enum struct Direction {
NORTH,
SOUTH,
EAST,
WEST,
};
int main(int argc, char* argv[]) {
// Scoped enum
Color color = Color::RED;
// Enum struct/class
Direction dir = Direction::NORTH;
// Unscoped C-style enum
CardSuit card1 = CLUBS;
CardSuit card2 = CardSuit::SPADES; // Can explicitly be scoped
// Implicit integer conversion
int suitValue = card1; // implicitly converts to int
// int colorValue = color; // fails, no implicit conversion
int colorValue = static_cast<int>(c); // explicit casts required
int dirValue = static_cast<int>(d);
}
The underlying type of an enumeration is an implementation-defined integral type that is large enough to hold all enumerated values; it does not have to be the smallest possible type. The underlying type can be specified directly.
// Must fit in size and memory layout of the type 'long'
enum class Color : long {
RED,
GREEN,
BLUE,
};
C++11 also allows forward declarations in which the enum values are not defined at the same time at the enum type itself. This is only possible if the underlying type is known before knowing of the enumerators. If an underlying type of a scoped enum is not defined, it defaults to int. If later the enumerators do not fit within this type, an error will arise.
// No explicit underlying type for enum class, so int
enum class Color;
// Explicit underlying type
enum class Status : unsigned char;
// Unscoped so underlying type is required
enum Legacy : int;
// Unscoped with no underlying type; error
// enum Broken;
// Forward declarations
void paint(Color c);
Status* getStatus();
// Later definitions
enum class Color {
RED,
GREEN,
BLUE,
};
enum class Status : unsigned char {
OK,
ERROR,
};
enum Legacy : int {
A,
B,
};
void paint(Color c) { /* ... */ }
Go
Go uses the iota identifier to create enumerated constants:1112
type ByteSize int
const (
_ = iota // ignore first value by assigning to blank identifier; 0
KB ByteSize = 1 << (10 * iota) // 1 << (10 * 1) == 1 << 10 == 1024; in binary 10000000000
MB // 1 << (10 * 2) == 1048576; in binary 100000000000000000000
GB // 1 << (10 * 3) == 1073741824; in binary 1000000000000000000000000000000
)
Java
The J2SE version 5.0 of the Java programming language added enumerated types whose declaration syntax is similar to that of C:
The Java type system, however, does not allow intermixing of enum and integer values. All enum types implicitly extend the Enum abstract class, so an enum cannot extend anything else, although it may implement any number of interfaces. The class java.lang.Enum<E> is constrained as Enum<E extends Enum<E>>, so enums can be self-referential. An enum type cannot be instantiated explicitly.13
Internally, an enum type becomes a special compiler-generated class rather than an arithmetic type, and enum values behave as global pre-generated instances of that class. Each enum value contains an integer called an ordinal, corresponding to the order in which they are declared in the source code, starting from 0. Enums implement Comparable and can be sorted with this ordinal. This internal value cannot be overridden, but it may be read with the ordinal() method (and the list of values through values()). To set an explicit order for the enum's members without rearranging them, one can implement overloaded constructors that assign an explicit value that acts as an order number. Since Enum.compareTo() is final, it cannot be overridden. Instead, a getter can be defined that returns this other number, which other programmers must explicitly use instead of the built-in comparison method. It is discouraged to treat enums as integers and vice versa.14
The Java standard library provides utility classes to use with enumerations. The EnumSet class implements a java.util.Set<E> of enum values; it is implemented as a bit array, which makes it very compact and as efficient as explicit bit manipulation, but safer. The EnumMap class implements a java.util.Map<K, V> where the enum's values are keys. It is implemented as an array, with the ordinal of the enum serving as the index.
Unlike C++, Java enums are first-class citizens like any other class and can have methods, constructors, and fields. Enum members may even override select methods, allowing members to be given specific method implementations. Abstract methods must be overridden by all members.
public enum Planet {
// Each member can call its own constructor (here, mass and radius)
MERCURY(3.303e+23, 2.4397e6),
VENUS(4.869e+24, 6.0518e6),
EARTH(5.976e+24, 6.37814e6) {
// Members may override methods
@Override
String touchdown() {
return "Home sweet home!";
}
// Abstract methods declared in an enum must be implemented by all members, however
},
MARS(6.421e+23, 3.3972e6),
JUPITER(1.9e+27, 7.1492e7),
SATURN(5.688e+26, 6.0268e7),
URANUS(8.686e+25, 2.5559e7),
NEPTUNE(1.024e+26, 2.4746e7);
// Enums may have static fields
public static final double G = 6.67300E-11;
// and fields specific to each member
public final double mass;
public final double radius;
// Constructors must not be public or protected
Planet(double mass, double radius) {
this.mass = mass;
this.radius = radius;
}
public double surfaceGravity() {
return Planet.G * this.mass / (this.radius * this.radius);
}
public double surfaceWeight(double otherMass) {
return otherMass * this.surfaceGravity();
}
public String touchdown() {
return "Woosh!";
}
// Entry methods are even allowed
public static void main(String[] args) {
double earthWeight = Double.parseDouble(args[0]);
double mass = earthWeight / EARTH.surfaceGravity();
for (Planet p : Planet.values()) {
System.out.printf(
"Your weight on %s is %.6f. %s%n",
p, p.surfaceWeight(mass), p.touchdown()
);
}
}
}
Perl
Dynamically typed languages in the syntactic tradition of C (e.g., Perl or JavaScript) do not, in general, provide enumerations. But in Perl programming the same result can be obtained with the shorthand stringslist and hashes (possibly slices):
my @enum = qw(Clubs Diamonds Hearts Spades);
my( %set1, %set2 );
@set1{@enum} = (); # all cleared
@set2{@enum} = (1) x @enum; # all set to 1
$set1{Clubs} ... # false
$set2{Diamonds} ... # true
Raku
Raku (formerly known as Perl 6) supports enumerations. There are multiple ways to declare enumerations in Raku, all creating a back-end Map.
enum Cat <sphynx siamese bengal shorthair other>; # Using "quote-words"
enum Cat ('sphynx', 'siamese', 'bengal', 'shorthair', 'other'); # Using a list
enum Cat (:sphynx(0), :siamese(1), :bengal(2), shorthair(3), :other(4)); # Another way of using Pairs, you can also use `:0sphynx`
PHP
Enums were added in PHP version 8.1.
enum CardSuit
{
case Hearts;
case Diamonds;
case Clubs;
case Spades;
}
Enumerators may be backed by string or integer values to aid serialization:
enum CardSuit: string
{
case Hearts = 'H';
case Diamonds = 'D';
case Clubs = 'C';
case Spades = 'S';
}
The Enum's interface exposes a method that gives a collection of its enumerators and their names. String/integer-backed Enums also expose the backing value and methods to (attempt) deserialization. Users may add further methods.
Rust
Though Rust uses the enum keyword like C, its enums are tagged unions, of which enums can be considered a degenerate form. Rust's enums are therefore much more flexible and its members can describe different data.
In Swift, enumerations do not need to provide a value for each member. If a value (termed a raw value) is explicitly provided for each enumeration case, the value can be a string, a character, or any integer or floating-point.
Alternatively, enumeration cases can specify associated values of any type to be stored along with each different case value, much as unions or variants do in other languages. One can define a common set of related cases as part of one enumeration, each of which has a different set of values of appropriate types associated with it.
In Swift, enumerations are a first-class type. They adopt many features traditionally supported only by classes, such as computed properties to provide additional information about the enumeration's current value, and instance methods to provide functionality related to the values the enumeration represents. Enumerations can also define initializers to provide an initial case value and can be extended to expand their functionality beyond their original implementation; and can conform to protocols to provide standard functionality.
enum CardSuit {
case clubs
case diamonds
case hearts
case spades
}
Unlike C and Objective-C, Swift enumeration cases are not assigned a default integer value when they are created. In the CardSuit example above, clubs, diamonds, hearts, and spades do not implicitly equal 0, 1, 2 and 3. Instead, the different enumeration cases are fully-fledged values in their own right, with an explicitly defined type of CardSuit.
Multiple cases can appear on a single line, separated by commas:
enum CardSuit {
case clubs, diamonds, hearts, spades
}
When working with enumerations that store integer or string raw values, one doesn't need to explicitly assign a raw value for each case because Swift will automatically assign the values.
For instance, when integers are used for raw values, the implicit value for each case is one more than the previous case. If the first case doesn't have a value set, its value is 0. For the CardSuit example, suits can be numbered starting from 1 by writing:
An enum module was added to the Python standard library in version 3.4. It introduces the class Enum which can be extended for defining enumerated types.
from enum import Enum
class CardSuit(Enum):
CLUBS: int = 1
DIAMONDS: int = 2
HEARTS: int = 3
SPADES: int = 4
There is also a functional API for creating enumerations with automatically generated indices (starting with 1):
Python enumerations do not enforce semantic correctness (a meaningless comparison to an incompatible enumeration always returns False rather than raising a TypeError):
Dart has a support for the most basic form of enums, with a familiar syntax:
enum CardSuit {
Clubs,
Diamonds,
Hearts,
Spades
}
void main() {
CardSuit card = CardSuit.Clubs;
// Dart uses the "switch" operator to match the value of an enum with the desired output.
switch (card) {
case CardSuit.Clubs: {
print("Clubs");
}
break;
case CardSuit.Diamonds: {
print("Diamonds");
}
break;
case CardSuit.Hearts: {
print("Hearts");
}
break;
case CardSuit.Spades: {
print("Spades");
}
break;
default: {
print("Unknown");
}
break;
}
}
Note that before Dart 3,15 the switch operator did not guarantee the completeness of the cases. So, if you omit one case, the compiler will not raise an error.
Other languages
COBOL
In COBOL, a condition-variable is a normal variable with subordinate level-88 fields, known as condition-names. Each condition-name must have a VALUE clause. The VALUE clause for a condition clause may specify either a single value or a list of values.
Fortran
Fortran 2003 introduced enumerators for interoperability with C; hence, the semantics is similar to C and, as in C, the enum values are just integers and no further type check is done. The C example from above can be written in Fortran as
enum, bind( C )
enumerator :: CLUBS = 1, DIAMONDS = 2, HEARTS = 4, SPADES = 8
end enum
Fortran 2023 introduced a true enumeration type. Values are ordered sequentially as specified. Intrinsic functions int and huge support enumerations. The functions next and previous are also available.
enumeration type :: days_of_week
enumerator :: monday, tuesday, wednesday, thursday, friday
enumerator :: saturday, sunday
end enumeration type
type (days_of_week) :: dow
:
if (dow == wednesday) then
print *, 'hump day'
end if
:
select case (dow)
case (monday:friday)
print *, 'weekday'
case (saturday, sunday)
print *, 'weekend'
end select
Enum CardSuit ' Zero-based Clubs Diamonds Hearts Spades End Enum Sub EnumExample() Dim suit As CardSuit suit = Diamonds MsgBox suit End Sub Enumerated datatypes are automatically assigned the "Long" datatype and also become a datatype themselves
Enum CardSuit Clubs Diamonds Hearts Spades End Enum Sub EnumExample() Dim suit As CardSuit suit = CardSuit.Diamonds MessageBox.show(suit) End Sub
(deftype cardsuit ()
'(member club diamond heart spade))
This states that object is of type cardsuit if it is #'eql to club, diamond, heart, or spade. The member type specifier is not valid as a Common Lisp Object System (CLOS) parameter specializer, however. Instead, (eql atom), which is the equivalent to (member atom) may be used (that is, only one member of the set may be specified with an eql type specifier, although it may be used as a CLOS parameter specializer). In other words, to define methods to cover an enumerated type, a method must be defined for each specific element of that type.
7Obasanjo, Dare (2007). "A Comparison of Microsoft's C# Programming Language to Sun Microsystems' Java Programming Language". Archived from the original on 2012-09-10. Retrieved 2012-09-06. “In Java, enumerated types are a full fledged class which means they are typesafe and can be extended by adding methods, fields or even implementing interfaces. Whereas in C#, an enumerated type is simply syntactic sugar around an integral type (typically an int) meaning they cannot be extended and are not typesafe.”{{cite web}}: CS1 maint: bot: original URL status unknown (link)
8Gruntz, Dominik, Prof. Dr. (2005-04-08). "Java 5: Taming the Tiger: Syntactic Sugar" (in German). Fachhochschule Aargau, Nordwestschweiz. Archived from the original on 2007-01-07. Retrieved 2012-09-10. “Enumerationen sind die heimlichen Sieger von Java 1.5. Nach vielen Beteuerungen durch Sun, Enums seien in Java überflüssig und können einfach nachgebildet werden, wurden sie nun doch eingeführt. Die einfachste Möglichkeit einer Enumeration der Jahreszeiten sieht wie folgt aus … Das Schlüsselwort enum steht für eine spezielle Art von Klasse, die eine Enumeration definiert. … Im Gegensatz zu anderen Programmiersprachen wie C/C++ und C# kann man ihnen per Gleichheitszeichen keine ganzen Zahlen zuordnen.”{{cite web}}: CS1 maint: multiple names: authors list (link) Alt URLArchived 2013-05-27 at the Wayback Machine
9Truter, Christoff (2011-08-04). "Syntactic sugar (C#): Enum". CSTrüter. Archived from the original on 2007-01-07. Retrieved 2012-09-10. “// Poorly designed enum don't do this … Obviously (like with everything else), we can misuse this piece of sugar ending up with a system suffering from hyperglycemia. … Seeing as the underlying type of our enum is an int (can also use other integral types) it can lead to some interesting issues when using an enum as bit flags via bitwise operators.”
11"Effective Go". golang.org. The Go Authors. Retrieved 2014-05-13.
12"Go Wiki: Iota - The Go Programming Language". go.dev. Retrieved 2025-05-15. “Go's iota identifier is used in const declarations to simplify definitions of incrementing numbers. Because it can be used in expressions, it provides a generality beyond that of simple enumerations”
In some high-level programming languages, a variable is an abstract storage or indirection location paired with an associated symbolic name, which contains some known or unknown quantity of data or…
Software that translates code from one programming language to another
In computing, a compiler is software that translates computer code written in one programming language (the source language) into another language (the target language).
In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these values as machine types.
In computer science, a tagged union, also called a variant, variant record, choice type, discriminated union, disjoint union, sum type, or coproduct, is a data structure used to hold a value that could take on several different, but fixed, types.
Collection of related items in a schema or ontology
A contrast set is a bounded collection of items, each of which could fill the same slot in a given schema, syntactic structure, or other linguistic environment.
In the area of mathematical logic and computer science known as type theory, a unit type is a type that allows only one value (and thus can hold no information).
In mathematical logic, and theoretical computer science, type theory is the study of formal systems that classify expressions or mathematical objects by their types.
In set theory, an ordinal number, or ordinal, is a generalization of ordinal numerals (first, second, nth, etc.) aimed to extend enumeration to infinite sets.
Letter case is the distinction between the letters that are in larger uppercase or capitals (more formally majuscule) and smaller lowercase (more formally minuscule) in the written representation of certain languages.
Camel case (sometimes stylized autologically as camelCase or CamelCase, also known as camel caps or more formally as medial capitals) is a writing format practice of writing phrases with capitalized words lacking spaces or punctuation.