Renderingen-US

promise

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

Promise-like result type associated with async finite functions.

Aliases: promise

Syntax: promise<T> | promise<T ⇥ E>

Category#

async

Examples#

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

Promise-like result type associated with async finite functions.

# =============================================================================
# promise — Promise-like result type associated with async finite functions.
# =============================================================================
#
# What this teaches:
#   • Async return type — `promise<T>` is the return-type wrapper for `async`
#     functions and compatibility `@ future` functions.
#   • Failable async return type — `promise<T ⇥ E>` preserves both the
#     resolved value and delayed alternate channel.
#
# Common mistakes:
#   • Creating a `promise<T>` but never awaiting it with `await_const`,
#     `await_var`, `return_await`, or `await` — the promise goes unobserved.
#
# See also: async, future, await_const, await
# =============================================================================

# promise<T> — async result type (paired with async)
#
# fn … async → <type>       -- lowers to promise<<type>>
# fn … async → <type> ⇥ E   -- lowers to promise<<type> ⇥ E>
#
# GRAMMAR:
#   futuraDecl :← funcDecl 'async'
#
# EXPECTED OUTPUT:
#   promise type notus (promissum.expected).

fn compute() async → int {
    return 7
}

main {
    print "promissum typus notus"
}

Expected output:

promissum typus notus