Ordinal Data Type¶
An ordinal data type gives its language-defined values ordered integer positions that support stepping and contiguous subranges.
Core Idea¶
An ordinal data type has a language-defined ordered set of values with integer positions. Operations such as obtaining a position, moving to a successor or predecessor, and specifying a contiguous subrange use that order. ISO Pascal explicitly uses the term ordinal-type: integer, Boolean, char, enumerated and subrange types qualify, while real is a separate simple type. Ada's current Reference Manual uses discrete type for enumeration and integer types and likewise assigns position numbers; its Day enumeration and Weekday subtype show the same core relation in a different language vocabulary.[1][2][3]
This is not a pure set-theoretic statement that any countable collection can be put into one-to-one correspondence with integers. The programming language must define the values, their order, legal operations and boundary behavior. A collection of strings is mathematically countable, but that fact alone does not give it Pascal's ord/succ operations. Ada even defines a machine successor operation on some non-discrete scalar types, so “has a next representable value” is not a sufficient cross-language admission rule.[1][2]
Structural Signature¶
Sig role-phrases:
- Language-defined value set: the literals or numeric values admitted by a type.
- Ordered integer positions: each legal value receives a position preserving the declared order.
- Step operations: successor and predecessor reach adjacent values where one exists.
- Bounded subrange: two ordered same-type values may delimit a contiguous subset.
- Language boundary: the standard decides which types and operations participate; mathematical countability or machine representation alone does not.[1][2]
In Pascal an enumeration literal's position is the count of literals before it. The standard gives (red, yellow, green, blue, tartan) and red..green as examples: the former establishes positions 0–4 and the latter selects the first three values. The same standard says succ and pred are errors when no neighboring value exists. Ada specifies the first enumeration literal's position as zero and increments each following literal by one; its Day and Weekday declarations similarly distinguish a base type from a constrained subset.[1][3]
What It Is Not¶
An ordinal type is not every ordered type. Pascal also has real values, but its standard separates real-type from ordinal-type. Ada's scalar hierarchy likewise includes real types but calls only enumeration and integer types discrete, even though it defines 'Succ for scalar subtypes, including a floating-point machine successor. Therefore the frozen seed's rationale “reals and strings have no next value” is wrong as a general argument; language-defined classification and operations are the boundary.[1][2]
Nor is a position number necessarily the object's whole physical storage representation. The standards establish semantic positions and permissible relationships, not a universal guarantee that every implementation stores a color or character in exactly one small integer cell. Pascal character ordinal values, for example, depend on its implementation-defined character set while still mapping consecutively from zero. Type semantics should not be conflated with a chosen encoding.[1]
Scope of Application¶
ISO/IEC 7185:1990 formalizes Pascal ordinal types in §§6.4.2.1–6.4.2.4 and gives ord, succ and pred in §6.6.6.4. Its range syntax permits same-host-type endpoints such as red..green and '0'..'9'; it also defines Boolean positions as false=0, true=1. The standard's exact cases are valuable because they show why the names' everyday meanings do not determine the type order: the declaration does.[1]
Ada 2022 §3.5 calls enumeration and integer types discrete and describes their position numbers. §3.5.1 gives type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun); and subtype Weekday is Day range Mon .. Fri; as official examples. This language uses attributes such as 'Succ and 'Pred, and range constraints have their own compatibility and error rules. We compare the shared positional mechanism without asserting that all Pascal and Ada edge semantics are identical.[2][3]
Clarity¶
Take Pascal's exact standard example (red, yellow, green, blue, tartan). The order of declaration, not wavelength or alphabetical order, gives ord(red)=0, ord(yellow)=1 and ord(green)=2. Thus succ(yellow)=green; pred(red) has no predecessor and is an error. The printed subrange red..green contains red, yellow and green, not blue or tartan. This is an executed application of the standard's rules to its own example.[1]
Take Ada's official Day list. Its position rule gives Mon=0, Tue=1, …, Fri=4, Sat=5, Sun=6. The declared Weekday subtype accepts Mon through Fri; Sat remains a valid Day value but is outside Weekday's constrained range. Day'Succ(Thu) gives Fri, while asking for a successor beyond Sun raises a boundary error under the relevant attribute rule. This is a subtype application, unlike Pascal's base enumeration computation.[2][3]
Manages Complexity¶
Position numbers let a language supply uniform operations over values whose programmer-facing labels differ. A Boolean can be ordered false before true; an enumeration can assign positions without hand-writing numeric constants; a subrange can constrain a larger host type. Those facilities can support array indexes, iteration or case selection where the language's grammar permits them. But this entry does not claim every ordinal type is accepted by every construct in every language; the exact standard governs use.[1][2]
The semantic distinction also helps detect illegal moves. succ is partial at the last enumerated value in Pascal, and Ada signals an error when an enumeration successor does not exist. A bounded subtype adds another constraint: a value may belong to the base type while failing the subtype's range, as Sat does for Weekday. This is stronger than merely labeling values with consecutive numbers, because the type checker/runtime can enforce specified bounds according to each language's rules.[1][2]
Abstract Reasoning¶
Let V be a type's ordered value set and p:V→ℤ its specified position function. For consecutive enumeration values vi and vi+1, p(vi+1)=p(vi)+1. A successor operation, where defined, returns the value at p(v)+1; a contiguous subrange [a,b] comprises values v with p(a)≤p(v)≤p(b). The mapping is within a particular declared type: two unrelated enumerations may both have a position 0 without their first values becoming interchangeable.[1][3]
Counterfactually, swapping yellow and green in Pascal's declaration reverses their positions and changes succ(red), even though the color words themselves remain the same. Giving Ada Weekday a bound through Sun would admit weekend days without changing the base Day enumeration. A raw string list could be sorted and counted externally, but unless the language provides a corresponding ordinal type and operations, the program's type relation has not been established.[1][2]
Knowledge Transfer¶
The diagnostic transfers from Pascal's ordinal vocabulary to Ada's discrete vocabulary: check type membership, integer positions, adjacent operations and subrange constraints in the actual language specification. What does not transfer automatically is the exact set of qualifying primitive types, the syntax for operations, or an implementation's memory layout. Similar operation names in another language must be checked against that language's own type rules before calling the category equivalent.[1][2]
The concept belongs to language semantics, not to mathematical ordinals in set theory. It is a strict specialization of the live Data Type entry: the broader type contract supplies values and operations, while the ordinal child adds language-defined integer positions, steps and subranges. No direct prime edge is asserted.
Examples¶
-
Pascal's named enumeration. ISO 7185 prints
(red, yellow, green, blue, tartan)andred..green. Mapped back: language-defined value set = those five literals; ordered integer positions = 0 through 4 in declaration order; step operations =succ(yellow)=green,pred(red)invalid; bounded subrange = first three literals; language boundary = the standard assigns order, not color semantics. This is a rule execution on the original standard's own example, not fabricated program output.[1] -
Ada's Day/Weekday subtype. The Ada 2022 Reference Manual prints a seven-value
Dayenumeration andWeekday is Day range Mon .. Fri. Mapped back: language-defined value set = Mon through Sun; integer positions = 0 through 6 by the official enumeration rule; step operations =Day'Succ(Thu)=Fri, with no value after Sun; bounded subrange = Weekday excludes Sat and Sun though they remain Day values; language boundary = an Ada discrete subtype's constraint, not a claim about real scalars. This is an unlike subtype use drawn from a second language standard.[2][3]
Structural Tensions¶
No universal intrinsic two-sided tension is established. Named literals versus numeric positions are two representations of the same specified order, and a bounded subtype versus its base type is a containment relation. The fact that bounds catch some values while restricting others can matter in a particular API design, but no language standard makes “safety versus flexibility” an inherent optimization of every ordinal type. The entry records a semantic class and its operations, not an invented design tradeoff.[1][2]
Structural–Framed Character¶
The type has a structural core—ordered positions and adjacent/range operations—but its scope is institutional: language standards specify which types are ordinal or discrete and what operations mean. Programmer practice values readable names and checked ranges, while a compiler implements the specified behavior. Pascal's formal ordinal terminology travels to Ada only through a real positional correspondence, not a claim that all their scalar classes or endpoint semantics are identical. Importing the term to any mathematically countable set would be analogy rather than recognition of a language-defined type. Its character: a programming-language semantic category in which integer position is attached to typed values and supports constrained ordered operations.[1][2]
Structural Core vs. Domain Accent¶
The skeletal relation is a specified order-preserving position map with adjacent steps and contiguous subsets. The domain-bound mechanism is a compiler/language-defined type whose legal values and errors are prescribed by a standard. The named entry fails the prime bar because stripping the language-defined type operations leaves any countable ordered set, far too broad to identify ordinal data types. A portable prime would need independently verified unlike settings and a live strict identity; none is asserted.[1]
Instantiates / Related Primes¶
This entry is a kind of Data Type.
What sets it apart within Data Type is a language-defined ordered set of values with integer positions; its broader ancestry comes through Data Type rather than being repeated here.
Pascal ordinal types and Ada discrete types are related language categories; neither is claimed as a parent of the other.[1][2]
Relationships to Other Abstractions¶
Current abstraction Ordinal Data Type Domain-specific
Parents (1) — more general patterns this builds on
-
Ordinal Data Type is a kind of Data Type Domain-specific
An ordinal data type is a data type with language-defined integer positions, step operations and contiguous subranges.Every ordinal data type specifies a computational value domain and legal operations, so it instantiates Data Type. The language-defined order, integer positions and successor/predecessor and subrange rules distinguish this child from data types without ordinal operations. Mathematical Order Type is not the computational genus.
Hierarchy path (1) — routes to 1 parentless root
- Ordinal Data Type → Data Type → Classification
Neighborhood in Abstraction Space¶
Ordinal Data Type sits in a sparse region of the domain-specific corpus (70th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.
Family — Type Systems & Functional Constructs (18 abstractions)
Nearest neighbors
- List (computing) — 0.84
- Signedness — 0.84
- Self-Organizing List — 0.84
- Rope (Data Structure) — 0.83
- Propositional logic — 0.83
Computed from structural-signature embeddings · 2026-10-08
Not to Be Confused With¶
- Every countable set of strings, absent language-defined position and operations.
- A real/floating scalar merely because some machine representation has a successor; Ada's scalar
'Succdoes not make real types discrete.[2] - Physical storage bits being exactly the semantic ordinal number in all implementations.[1]
- Mathematical ordinal numbers in set theory, which are not this programming-language type category.
References¶
[1] ISO/IEC 7185:1990, Programming languages—Pascal, original standard, §§6.4.2.1–6.4.2.4 (pp. 20–22) and §6.6.6.4 (p. 50), including official enumeration/subrange examples and ord, succ, pred rules. registry ↩a ↩b ↩c ↩d ↩e ↩f ↩g ↩h ↩i ↩j ↩k ↩l ↩m ↩n ↩o ↩p ↩q ↩r ↩s
[2] Ada 2022 Reference Manual, authoritative language reference, §3.5 “Scalar Types”: discrete types, position numbers, ranges and successor/predecessor attributes. registry ↩a ↩b ↩c ↩d ↩e ↩f ↩g ↩h ↩i ↩j ↩k ↩l ↩m ↩n ↩o
[3] Ada 2022 Reference Manual, authoritative language reference, §3.5.1 “Enumeration Types”: position-number rule and official Day/Weekday examples. registry ↩a ↩b ↩c ↩d ↩e ↩f