期约
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.
Promise-like result type associated with async finite functions.
Aliases: promise
Syntax: 期约<T> | 期约<T ⇥ E>
Category#
async
Related#
Examples#
radix/corpus/promissum/promissum.fab (canonical · keyword)#
Promise-like result type associated with async finite functions.
# =============================================================================
# 期约 — Promise-like result type associated with async finite functions.
# =============================================================================
#
# What this teaches:
# • Async return type — `期约<T>` is the return-type wrapper for `异步`
# functions and compatibility `@ 未来` functions.
# • Failable async return type — `期约<T ⇥ E>` preserves both the
# resolved value and delayed alternate channel.
#
# Common mistakes:
# • Creating a `期约<T>` but never awaiting it with `等定`,
# `等变`, `等返`, or `等弃` — the promise goes unobserved.
#
# See also: 异步, 未来, 等定, 等弃
# =============================================================================
# 期约<T> — async result type (paired with 异步)
#
# 函数 … 异步 → <类型> -- lowers to 期约<<类型>>
# 函数 … 异步 → <类型> ⇥ E -- lowers to 期约<<类型> ⇥ E>
#
# GRAMMAR:
# futuraDecl :← funcDecl '异步'
#
# EXPECTED OUTPUT:
# 期约 类型 notus (promissum.expected).
fn compute() async → int {
return 7
}
main {
print "promissum typus notus"
}Expected output:
promissum typus notus