Renderingen-US

async_generator

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

Callable posture for asynchronous stream functions.

Aliases: async_generator

Syntax: fn name(…) async_generator → T

Category#

async

Examples#

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

Callable posture for asynchronous stream functions.

# =============================================================================
# async_generator — Asynchronous stream callable posture
# =============================================================================
#
# What this teaches:
#   • Async stream posture: `async_generator → T` yields promised pulls of `T`.
#   • Yield with `yield`; consume the stream with `for from` inside an async body.
#
# Common mistakes:
#   • Expecting every backend to lower `async_generator` — some fail closed until a
#     channel/async-cursor carrier lands.
#
# See also: generator, async, yield
# =============================================================================

# GRAMMAR:
#   callablePosture :← 'async_generator'
#
# BACKEND:
#   Product path is Rust async-cursor; other backends may fail closed.

fn stream() async_generator → int {
    yield 1
    yield 2
}

async_main {
    for from stream() const n {
        print n
    }
}

Expected output:

1
2