افعل
Translation status: العربية reader-locale proof. Term names and code fences follow the ar pack; supporting prose may still be English.
Starts a scoped do-while style loop.
Aliases: do
Syntax: افعل <block> [التقط <name> <block>] [طالما <condition>]
Category#
control-flow
Related#
Examples#
radix/corpus/fac/fac-cape.fab (canonical · keyword)#
Starts a scoped do-while style loop.
# =============================================================================
# افعل — Starts a scoped do-while style loop
# =============================================================================
#
# What this teaches:
# • Starts a scoped do-while style loop.
# • Related keywords: طالما, التقط, إغلاق, تابع
#
# Common mistakes:
# • Using `التقط` on a non-`افعل` block — `التقط` only attaches to `افعل` statements, not arbitrary blocks.
#
# See also: طالما, التقط, إغلاق, تابع
# =============================================================================
# افعل — try block with التقط error handler
#
# افعل { <body> }
# التقط err { <handler> }
#
# GRAMMAR:
# facStmt :← 'افعل' block 'التقط' ident block
#
# EXPECTED OUTPUT:
# none — success path then simulated failure on attempt 2
#
# BACKEND:
# Rust/Go: افعل/cape not yet emitted — compile-only smoke.
main {
do {
print "Block executed successfully"
}
catch err {
print "Caught error: §"(err.nuntius)
}
# ارم on second attempt; التقط recovers and prints err.nuntius
var int attempts ← 0
do {
attempts ← attempts + 1
print "Attempt §"(attempts)
if attempts ≡ 2 {
throw "Simulated failure"
}
}
catch err {
print "Failed on attempt §: §"(attempts, err.nuntius)
}
}