Renderingla

secus

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

Aliases: else, otherwise

Syntax: secus <block>

Category

control-flow

Related

Examples

examples/corpus/secus/secus.fab (canonical · keyword)

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

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

incipit {
    fixum _ hour ← 23
    si hour < 12 {
        nota "morning"
    }
    secus {
        nota "afternoon-or-later"
    }
}

Expected output:

afternoon-or-later

examples/corpus/si/secus.fab (canonical · keyword)

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

# 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.

incipit {
    # Two-way branch: exactly one arm runs
    fixum _ puncta ← 85

    si puncta ≥ 90 {
        nota "gradus: A"
    }
    secus {
        # 85 < 90 → this arm
        nota "gradus: B aut minor"
    }

    # Each branch may contain several statements
    fixum _ calor ← 22

    si calor > 30 {
        nota "calidum"
        nota "aquam bibe"
    }
    secus {
        # 22 ≤ 30
        nota "commodum"
        nota "caelum mite"
    }

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

    si gradus ≥ 90 {
        nota "A - optimum"
    }
    sin gradus ≥ 80 {
        nota "B - bonum"
    }
    sin gradus ≥ 70 {
        nota "C - satis"
    }
    sin gradus ≥ 60 {
        nota "D - transit"
    }
    secus {
        nota "F - deficit"
    }
}

Expected output:

gradus: B aut minor
commodum
caelum mite
C - satis