Topic: constants
Topic: kinds of numbers
Topic: non-primitive values
Topic: ordered data types
Topic: range data type
Topic: variant data types
Topic: state machine
Topic: value as an abstraction
Topic: value as an object
| |
Summary
An enumerated type consists of a set of named states. It implements a state variable without specifying the numerical representation of each state. Enumerated types generalize boolean types with their 'true' and 'false' states. Enumerated types may be replaced, tested, or used as a set of constants. The next state in an ordered, enumerated type can be selected. (cbb 5/80)
Subtopic: enumerated constants
Quote: use enumerated data type to define a new set of constants [»demeA3_1979]
| Quote: all enumerated and subrange types have standard set of accessing functions such as 'first' and 'pred' [»veneT3_1978]
| Quote: declare classes for enumerations and enumeration constants, with objects for enumeration values [»linsC7_1990]
| Subtopic: enumeration as int
Quote: a C enumeration is really treated as 'int'; not useful for tagged unions [»jimT6_2002]
| Quote: programmers used integer and character values as status values; indicated by comments [»goodJB2_1976]
| Subtopic: enumeration as case statement
Note: an enum function is a case statement; guarantees a set of functions by object [»cbb_2000, OK]
| Subtopic: string literals as enumeration
Quote: strings are poor substitutes for value types, enumerated types, and aggregate types [»blocJ_2001]
| Subtopic: notation
Quote: for values in enumerated sets, the qualifier describes the particular element; e.g., 'coRed'
| QuoteRef: hehnEC7_1975 ;;6 ordered or unordered literal values named by listing eg red, blue, green: v
| QuoteRef: sammJE5_1962 ;;126 condition names (symbolic values eg true)
| QuoteRef: wirtN1_1971 ;;41 scalar types by enumeration of literals (ordered so succ and pred func) eg colors = (red, orange, yellow, blue) succ (red) == orange
| QuoteRef: wirtN1_1971 ;;42 array [boolean (true or false)] of color [red orange yellow blue]
| Subtopic: problems with enumeration
Quote: enumeration types should be dropt; defy extensibility and, with subranges, lead to a type explosion [»wirtN7_1988]
| Quote: need to use named constants instead of enumerations if separate definition from implementation; otherwise need to recompile everything [»linsC7_1990]
| Quote: if enumerations define array bounds, then the size of an array depends on the enumeration's definition [»linsC7_1990, OK]
| Quote: an enumeration not only specifies names but also their ordinal positions; creates hidden information and dependencies [»linsC7_1990]
| Quote: Oberon users do not miss enumerations, subranges, submodules, automatic qualifications, general indexing, for-statements, etc. [»wirtN9_1989]
|
Related Topics
Topic: constants (21 items)
Topic: kinds of numbers (24 items)
Topic: non-primitive values (11 items)
Topic: ordered data types (8 items)
Topic: range data type (17 items)
Topic: variant data types (7 items)
Topic: state machine (67 items)
Topic: value as an abstraction (25 items)
Topic: value as an object (29 items)
|