lời_hứa
Translation status: Tiếng Việt reader-locale proof. Term names and code fences follow the vi pack; supporting prose may still be English.
Promise-like result type associated with async finite functions.
Aliases: promise
Syntax: lời_hứa<T> | lời_hứa<T ⇥ E>
Category#
async
Related#
Examples#
radix/corpus/promissum/promissum.fab (canonical · keyword)#
Promise-like result type associated with async finite functions.
# =============================================================================
# lời_hứa — Promise-like result type associated with async finite functions.
# =============================================================================
#
# What this teaches:
# • Async return type — `lời_hứa<T>` is the return-type wrapper for `async`
# functions and compatibility `@ tương_lai` functions.
# • Failable async return type — `lời_hứa<T ⇥ E>` preserves both the
# resolved value and delayed alternate channel.
#
# Common mistakes:
# • Creating a `lời_hứa<T>` but never awaiting it with `đợi_hằng`,
# `đợi_biến`, `đợi_trả`, or `đợi_bỏ` — the promise goes unobserved.
#
# See also: async, tương_lai, đợi_hằng, đợi_bỏ
# =============================================================================
# lời_hứa<T> — async result type (paired with async)
#
# hàm … async → <kiểu_tên> -- lowers to lời_hứa<<kiểu_tên>>
# hàm … async → <kiểu_tên> ⇥ E -- lowers to lời_hứa<<kiểu_tên> ⇥ E>
#
# GRAMMAR:
# futuraDecl :← funcDecl 'async'
#
# EXPECTED OUTPUT:
# lời_hứa kiểu_tên notus (promissum.expected).
fn compute() async → int {
return 7
}
main {
print "promissum typus notus"
}Expected output:
promissum typus notus