迭代器
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.
Compatibility annotation for stream/generator posture.
Syntax: @ 迭代器
Category#
async
Related#
Examples#
radix/corpus/cursor/cursor.fab (canonical · keyword)#
Compatibility annotation for stream/generator posture.
# =============================================================================
# 迭代器 — Compatibility annotation for stream/generator posture.
# =============================================================================
#
# What this teaches:
# • Preferred stream posture — write `流` for a synchronous stream or
# `异流` for an asynchronous stream.
# • Compatibility annotation — `@ 迭代器` remains accepted and preserved as
# the legacy spelling for stream/generator posture.
#
# Common mistakes:
# • Using `让出` outside a stream body — `让出` is valid only inside `流`
# or `异流` bodies, including compatible `@ 迭代器` declarations.
#
# See also: 流, 异流, 让出
# =============================================================================
# 迭代器 — compatibility stream annotation
#
# GRAMMAR:
# annotation :← '@' '迭代器'
# callablePosture :← '流' | '异流'
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
# BACKEND:
# Cross-ref: 未来/futura.fab, 遍历/cursor-iteratio.fab; Go whitelist: 迭代器/cursor.fab.
#
@ 迭代器 { }
fn stream() → int {
yield 1
yield 2
}
main {
print stream()
}Expected output:
[1, 2]