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