العرضar

secus

Translation status: العربية reader-locale proof. Code fences render through the ar pipeline; prose is canonical Latin.

Runs the fallback branch when preceding conditional branches do not match.

Aliases: else, otherwise

Syntax: secus <block>

Category#

control-flow

Examples#

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

Runs the fallback branch when preceding conditional branches do not match.

# =============================================================================
# secus — Runs the fallback branch when preceding conditional branches do not
# match.
# =============================================================================
#
# What this teaches:
#   • Conditional fallback — `secus` provides the else/otherwise branch that
#     runs when no preceding `si` or `sin` condition matched
#   • Always comes last in an if-else chain; takes a block body
#
# Common mistakes:
#   • Writing `secus si` instead of the canonical `sin` for else-if branches — `secus` must always be final.
#
# See also: si, sin
# =============================================================================

# secus — final else branch
#
# GRAMMAR:
#   elseClause :← 'secus' block
#
# EXPECTED OUTPUT:
#   Scalar stdout smoke (see body).
#
# BACKEND:
#   Cross-ref: si/secus.fab.
#

main {
    const _ hour  23
    if hour < 12 {
        print "morning"
    }
    else {
        print "afternoon-or-later"
    }
}

Expected output:

afternoon-or-later

radix/corpus/si/secus.fab (canonical · keyword)#

Runs the fallback branch when preceding conditional branches do not match.

# =============================================================================
# secus — Runs the fallback branch when preceding conditional branches do not
# match.
# =============================================================================
#
# What this teaches:
#   • If-else branches — `si { } secus { }` provides two-way branching; exactly
#     one arm executes
#   • `sin` chains additional conditions before the final `secus` fallback;
#     first match wins
#
# Common mistakes:
#   • TODO: placing `secus` before a `sin` branch — `secus` must always be the
#     final clause
#
# See also: si, sin
# =============================================================================

# si-secus (if-else) conditionals
#
# si <condition> { <body> }                                   -- two-way branch
# secus { <body> }
# si <cond1> { }                                              -- else-if chain
# sin <cond2> { }
# secus { }
#
# GRAMMAR:
#   ifStmt :← 'si' expr block ('sin' expr block)* ('secus' block)?
#
# EXPECTED OUTPUT:
#   Grade and weather messages for sample scores and temperatures.

main {
    # Two-way branch: exactly one arm runs
    const _ puncta  85

    if puncta  90 {
        print "gradus: A"
    }
    else {
        # 85 < 90 → this arm
        print "gradus: B aut minor"
    }

    # Each branch may contain several statements
    const _ calor  22

    if calor > 30 {
        print "calidum"
        print "aquam bibe"
    }
    else {
        # 22 ≤ 30
        print "commodum"
        print "caelum mite"
    }

    # sin chains additional tests; first match wins (75 → C)
    const _ gradus  75

    if gradus  90 {
        print "A - optimum"
    }
    elif gradus  80 {
        print "B - bonum"
    }
    elif gradus  70 {
        print "C - satis"
    }
    elif gradus  60 {
        print "D - transit"
    }
    else {
        print "F - deficit"
    }
}

Expected output:

gradus: B aut minor
commodum
caelum mite
C - satis