Posted to tcl by hypnotoad at Tue Nov 29 19:00:21 GMT 2016view raw
- proc coro_with_args {x} {
- while 1 {
- set m [yield]
- puts "We are at $x $m"
- }
- }
- coroutine CORO coro_with_args 0
- for {set i 0} {$i < 10} {incr i 2} {
- CORO $i
- }
- -----
- $ tclsh test_coro.tcl
- We are at 0 0
- We are at 0 2
- We are at 0 4
- We are at 0 6
- We are at 0 8