Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
- Coroutines (generator-style): coroutine/yield/yieldto commands; eager yield collection during body execution, pop-on-call dispatch via registered command closures; coro-yields + coroutines threaded through tcl-call-proc - info exists varname (plus hostname/script/tclversion stubs) - clock seconds/milliseconds/format/scan stubs - File I/O stubs: open/close/read/eof/seek/tell/flush + file subcommands - format command: full %-specifier parsing with flags, width, zero-pad, left-align - Fixed dict set/unset/incr/append/update to use tcl-var-get (upvar alias aware) - Fixed lappend and append to use tcl-var-get for reading (upvar alias aware) - 20 coroutine tests (coro.sx) + 20 idiom corpus tests (idioms.sx) - event-loop.tcl program: cooperative scheduler demo using coroutines - Note: coroutines eagerly collect yields (generator-style, not true suspension) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
23 lines
426 B
Tcl
23 lines
426 B
Tcl
# expected: done
|
|
# Cooperative scheduler demo using coroutines (generator style)
|
|
# coroutine eagerly collects all yields; invoking the coroutine name pops values
|
|
|
|
proc counter {n max} {
|
|
while {$n < $max} {
|
|
yield $n
|
|
incr n
|
|
}
|
|
yield done
|
|
}
|
|
|
|
coroutine gen1 counter 0 3
|
|
|
|
# gen1 yields: 0 1 2 done
|
|
set out {}
|
|
for {set i 0} {$i < 4} {incr i} {
|
|
lappend out [gen1]
|
|
}
|
|
|
|
# last val is "done"
|
|
lindex $out 3
|