渲染zh-Hans

异步入口

Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.

Declares the asynchronous program entry point.

Syntax: 异步入口 <block>

Category#

entry

Examples#

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

Declares the asynchronous program entry point.

# =============================================================================
# 异步入口 — Declares the asynchronous program entry point
# =============================================================================
#
# What this teaches:
#   • Declares the asynchronous program entry point.
#   • Related keywords: 入口, 等定, 等弃
#
# Common mistakes:
#   • Calling a `异步` function without consuming its 期约; use
#     `等定`, `等变`, `等返`, or `等弃` inside an `异步入口`.
#
# See also: 入口, 等定, 等弃
# =============================================================================

# 异步入口 — async program entry point
#
# 异步入口 { <body> }
#
# GRAMMAR:
#   asyncEntry :← '异步入口' block
#
# EXPECTED OUTPUT:
#   none — Rust async runtime whitelist (compile-only in harness)
#
# BACKEND:
#   Pairs with `异步` and awaited bindings; contrast with 入口
#   (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 异步 functions with 等定
    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