Renderingen-US

async_main

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

Declares the asynchronous program entry point.

Syntax: async_main <block>

Category#

entry

Examples#

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

Declares the asynchronous program entry point.

# =============================================================================
# async_main — Declares the asynchronous program entry point
# =============================================================================
#
# What this teaches:
#   • Declares the asynchronous program entry point.
#   • Related keywords: main, await_const, await
#
# Common mistakes:
#   • Calling a `async` function without consuming its promise; use
#     `await_const`, `await_var`, `return_await`, or `await` inside an `async_main`.
#
# See also: main, await_const, await
# =============================================================================

# async_main — async program entry point
#
# async_main { <body> }
#
# GRAMMAR:
#   asyncEntry :← 'async_main' block
#
# EXPECTED OUTPUT:
#   none — Rust async runtime whitelist (compile-only in harness)
#
# BACKEND:
#   Pairs with `async` and awaited bindings; contrast with main
#   (synchronous entry).

# Helper async finite function
fn accipe() async → string {
    # Simulates async finite operation
    return "datum paratum"
}

fn metire(string datum) async → int {
    return datum.length()
}

# Futura entry point
async_main {
    print "incipiet initium"

    # Await async functions with await_const
    await_const string datum ← accipe()
    print "acceptum: §"(datum)
    await_const int longitudo ← metire(datum)
    print "longitudo: §"(longitudo)
    print "opus perfectum"
}

Expected output:

incipiet initium
acceptum: datum paratum
longitudo: 13
opus perfectum