làm
Translation status: Tiếng Việt reader-locale proof. Term names and code fences follow the vi pack; supporting prose may still be English.
Starts a scoped do-while style loop.
Aliases: do
Syntax: làm <block> [bắt <name> <block>] [trong_khi <condition>]
Category#
control-flow
Related#
Examples#
radix/corpus/fac/fac-cape.fab (canonical · keyword)#
Starts a scoped do-while style loop.
# =============================================================================
# làm — Starts a scoped do-while style loop
# =============================================================================
#
# What this teaches:
# • Starts a scoped do-while style loop.
# • Related keywords: trong_khi, bắt, đóng, tiếp
#
# Common mistakes:
# • Using `bắt` on a non-`làm` block — `bắt` only attaches to `làm` statements, not arbitrary blocks.
#
# See also: trong_khi, bắt, đóng, tiếp
# =============================================================================
# làm — try block with bắt error handler
#
# làm { <body> }
# bắt err { <handler> }
#
# GRAMMAR:
# facStmt :← 'làm' block 'bắt' ident block
#
# EXPECTED OUTPUT:
# none — success path then simulated failure on attempt 2
#
# BACKEND:
# Rust/Go: làm/cape not yet emitted — compile-only smoke.
main {
do {
print "Block executed successfully"
}
catch err {
print "Caught error: §"(err.nuntius)
}
# ném on second attempt; bắt 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)
}
}