Renderingla

fac

Starts a scoped do-while style loop.

Aliases: do

Syntax: fac <block> [cape <name> <block>] [dum <condition>]

Category

control-flow

Related

Examples

examples/corpus/fac/fac-cape.fab (canonical · keyword)

Starts a scoped do-while style loop.

# fac — try block with cape error handler
#
# fac { <body> }
# cape err { <handler> }
#
# GRAMMAR:
#   facStmt :← 'fac' block 'cape' ident block
#
# EXPECTED OUTPUT:
#   none — success path then simulated failure on attempt 2
#
# BACKEND:
#   Rust/Go: fac/cape not yet emitted — compile-only smoke.

incipit {
    fac {
        nota "Block executed successfully"
    }
    cape err {
        nota "Caught error: §"(err.nuntius)
    }

    # iace on second attempt; cape recovers and prints err.nuntius
    varia numerus attempts ← 0
    fac {
        attempts ← attempts + 1
        nota "Attempt §"(attempts)
        si attempts ≡ 2 {
            iace "Simulated failure"
        }
    }
    cape err {
        nota "Failed on attempt §: §"(attempts, err.nuntius)
    }
}