คำมั่น
Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH 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