渲染zh-Hant

異流

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

Callable posture for asynchronous stream functions.

Aliases: async_generator

Syntax: 函式 name(…) 異流 → T

Category#

async

Examples#

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

Callable posture for asynchronous stream functions.

# =============================================================================
# 異流 — Asynchronous stream callable posture
# =============================================================================
#
# What this teaches:
#   • Async stream posture: `異流 → T` yields promised pulls of `T`.
#   • Yield with `讓出`; consume the stream with `遍歷 取自` inside an async body.
#
# Common mistakes:
#   • Expecting every backend to lower `異流` — some fail closed until a
#     channel/async-cursor carrier lands.
#
# See also: 流, 異步, 讓出
# =============================================================================

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

函式 stream() 異流 → 整數 {
    讓出 1
    讓出 2
}

非同步入口 {
    遍歷 取自 stream() 定值 n {
        註記 n
    }
}

Expected output:

1
2