التقط
Translation status: العربية reader-locale proof. Term names and code fences follow the ar pack; supporting prose may still be English.
Starts a catch block.
Aliases: catch
Syntax: <structured-statement> التقط <name> <block>
Category#
errors
Related#
Examples#
radix/corpus/cape/cape.fab (canonical · keyword)#
Starts a catch block.
# =============================================================================
# التقط — Starts a catch block.
# =============================================================================
#
# What this teaches:
# • Error recovery — `افعل { … } التقط err { … }` attempts a block and catches
# errors with a named handler
# • Guarded execution — code inside the `افعل` block can `ارم` errors that
# are intercepted by the `التقط` handler
#
# Common mistakes:
# • attaching `التقط` to a bare `{ }` block — `التقط` only attaches to `افعل` blocks and structured statements; use `افعل { ... } التقط err { ... }`
#
# See also: افعل, ارم, ⇥
# =============================================================================
# التقط — catch handler on افعل
#
# GRAMMAR:
# facStmt :← 'افعل' block 'التقط' ident block
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
# BACKEND:
# Rust/Go: افعل/cape emit gap (whitelist: التقط/cape.fab).
#
main {
var int attempt ← 0
do {
attempt ← attempt + 1
if attempt ≻ 1 {
throw "simulated failure"
}
print "attempt §"(attempt)
}
catch err {
print "caught"
}
}Expected output:
attempt 1
radix/corpus/cape/receptio-decline.fab (supporting · reject)#
التقط AIR decline rows: whole-loop طالما/itera التقط stays out under the loop-spectrum causes, a rethrow from a recovery arm declines (rethrow_in_recovery).
# =============================================================================
# receptio decline — the Tier 0.5 keep-outs stay fail-closed.
# =============================================================================
#
# Decline rows (reject reason in each comment):
# 1. whole-loop التقط on `طالما` — one trailing التقط wraps the whole loop
# (never re-armed per iteration), and the loop spectrum stays an AIR
# keep-out: SEM059 dum_loop. A loop statement has no normal-exit
# value, so the recovery arm also fails the outer-type rule:
# SEM059 recovery_type_mismatch
# 2. whole-loop التقط on `كرر` — same per-loop attachment, same
# keep-out: SEM059 itera_loop plus recovery_type_mismatch
# 3. rethrow — a throw from inside the catch arm is a rethrow; it
# declines to Tier 2 fail-closed and is never silently treated as a
# recovered value: SEM059 rethrow_in_recovery
#
# Common mistakes:
# • expecting the trailing loop `التقط` to recover per iteration — the
# handler is per-loop by the grammar; per-iteration recovery would
# need new syntax and its own goal
# • expecting a rethrow to admit because the region admitted — the
# recovery arm is checked as a catch region; throwing from it is the
# named Tier 2 decline
#
# See also: التقط, طالما, كرر, ارم, receptio-air
# =============================================================================
# 1. whole-loop التقط on طالما — loop-spectrum keep-out
@ radix مسار "air"
دالة custos_dum(منطقي pergo) → فراغ {
طالما pergo {
ارم "x"
} التقط err { }
}
# 2. whole-loop التقط on كرر — loop-spectrum keep-out
@ radix مسار "air"
دالة custos_itera() → فراغ {
كرر نطاق 0‥4 ثابت i {
ارم "x"
} التقط err { }
}
# 3. rethrow — a throw inside the catch arm declines to Tier 2
@ radix مسار "air"
دالة reicit(منطقي malum) → عدد ⇥ نص {
افعل {
إذا malum { ارم "x" }
أعد 1
} التقط err {
ارم "reicitur"
}
أعد 2
}Expected: compilation rejects this example.