渲染zh-Hans

流

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

Callable posture for synchronous stream (generator) functions.

Aliases: generator

Syntax: 函数 name(…) 流 → T

Category#

async

Examples#

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

Callable posture for synchronous stream (generator) functions.

# =============================================================================
# 流 — Synchronous stream callable posture
# =============================================================================
#
# What this teaches:
#   • Preferred stream posture: `流 → T` yields `T` items.
#   • Yield with statement-initial `让出 value` inside the body.
#
# Common mistakes:
#   • Using `@ 迭代器` only when teaching preferred morphology — prefer `流`.
#
# See also: 迭代器, 让出, 异流
# =============================================================================

# GRAMMAR:
#   callablePosture :← '流'
#   yieldStmt :← '让出' expr
#
# EXPECTED OUTPUT:
#   [1, 2]

函数 stream() 流 → 整数 {
    让出 1
    让出 2
}

入口 {
    显示 stream()
}

Expected output:

[1, 2]