渲染zh-Hant

等定

Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.

Awaits a 承諾 and binds an immutable name.

Aliases: await_const

Syntax: 等定 T name ← future

Category#

async

Examples#

radix/corpus/figendum/figendum.fab (canonical · keyword)#

Awaits a 承諾 and binds an immutable name.

# =============================================================================
# 等定 — Await-bind immutable
# =============================================================================
#
# What this teaches:
#   • Await a `承諾<T>` and bind the success value immutably.
#   • Valid in `異步` / `異流` / `非同步入口` contexts.
#
# See also: 等變, 等棄, 等返, 異步, 承諾
# =============================================================================

# GRAMMAR:
#   awaitBind :← '等定' type? IDENT '←' expr

函式 responde() 異步 → 整數 {
    傳回 7
}

非同步入口 {
    等定 整數 responsum ← responde()
    註記 responsum
}

Expected output:

7