العرضar

ترتيب

Translation status: العربية reader-locale proof. Term names and code fences follow the ar pack; supporting prose may still be English.

Declares an enumeration.

Aliases: enum

Syntax: ترتيب <name> <block>

Category#

type

Examples#

radix/corpus/ordo/ordo.fab (canonical · keyword)#

Declares an enumeration.

# =============================================================================
# ترتيب — Declares an enumeration.
# =============================================================================
#
# What this teaches:
#   • Enumeration declaration — `ترتيب <Name> { member, ... }` declares a set of ordered, named constants.
#   • Discriminant values — Members can have explicit numeric values with `= <number>`.
#   • Pattern matching — `اختر` with `حالة` branches selects on ترتيب variants.
#
# Common mistakes:
#   • Confusing ترتيب (enum with named constants) with تمايز (tagged union with payloads) — ترتيب members carry no data.
#
# See also: تمايز
# =============================================================================

# ترتيب — enumerated constants (ordered variants)
#
# ترتيب <Nomen> { <membrum>, … }
# ترتيب <Nomen> { <membrum> = <قيمة>, … }
#
# GRAMMAR:
#   ordoDecl :← 'ترتيب' ident '{' ordoMember (',' ordoMember)* '}'
#
# EXPECTED OUTPUT:
#   rubrum
#   actum

enum Color {
    rubrum,
    viridis,
    caeruleum
}

enum Condicio {
    pendens = 0,
    actum = 1,
    finitum = 2
}

main {
    # Using ترتيب values: members are qualified by their ترتيب name
    const Color color ← Color.rubrum
    const Condicio condicio ← Condicio.actum

    # Select by ترتيب
    switch color {
        case Color.rubrum {
            print "rubrum"
        }
        case Color.viridis {
            print "viridis"
        }
        case Color.caeruleum {
            print "caeruleum"
        }
    }

    # Select by ترتيب with numeric values
    switch condicio {
        case Condicio.pendens {
            print "pendens"
        }
        case Condicio.actum {
            print "actum"
        }
        case Condicio.finitum {
            print "finitum"
        }
    }
}

Expected output:

rubrum
actum