Posted to tcl by aspect at Tue Apr 04 02:25:54 GMT 2017view raw
- proc coroeval { coro script } {
- uplevel 1 [format {%s;%s} \
- [list ::tcl::unsupported::inject $coro try [format { yield [try {%s} on error {} {}] } $script]] \
- $coro
- ]
- }
- coroutine foo while 1 yield
- for {set i 0} {$i < 1000} {incr i} {
- coroeval foo {incr ::j}
- }