العرضar

وعد

Translation status: العربية reader-locale proof. Term names and code fences follow the ar pack; supporting prose may still be English.

Promise-like result type associated with async finite functions.

Aliases: promise

Syntax: وعد<T> | وعد<T ⇥ E>

Category#

async

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