Posted to tcl by hypnotoad at Tue Nov 29 19:00:21 GMT 2016view raw

  1. proc coro_with_args {x} {
  2. while 1 {
  3. set m [yield]
  4. puts "We are at $x $m"
  5. }
  6. }
  7. coroutine CORO coro_with_args 0
  8. for {set i 0} {$i < 10} {incr i 2} {
  9. CORO $i
  10. }
  11.  
  12. -----
  13. $ tclsh test_coro.tcl
  14. We are at 0 0
  15. We are at 0 2
  16. We are at 0 4
  17. We are at 0 6
  18. We are at 0 8