Posted to tcl by kbk at Fri Apr 23 17:19:34 GMT 2010view raw

  1. namespace eval ::tcl::unsupported {namespace export yieldTo}
  2. namespace import ::tcl::unsupported::yieldTo
  3.  
  4. proc pro {} {
  5. puts "creating producer"
  6. yield
  7. puts "producer starting"
  8. for {set i 0} {$i < 10} {incr i} {
  9. yieldTo consumer $i
  10. }
  11. puts "producer yielding end of stream"
  12. yieldTo consumer {}
  13. puts "producer returning"
  14. }
  15.  
  16. proc con {} {
  17. puts "creating consumer"
  18. yield
  19. puts "consumer starting"
  20. while {[set i [yieldTo producer]] != {}} {
  21. puts $i
  22. }
  23. puts "consumer returning"
  24. }
  25.  
  26.  
  27. coroutine producer pro
  28. coroutine consumer con
  29. consumer
  30.  
  31. coroutine producer pro
  32. coroutine consumer con
  33. producer

Comments

Posted by kbk at Fri Apr 23 17:20:22 GMT 2010 [text] [code]

creating producer creating consumer consumer starting Tailcall cannot find the right splicing spot: should not happen! This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.