Posted to tcl by kbk at Fri Apr 23 17:19:34 GMT 2010view raw
- namespace eval ::tcl::unsupported {namespace export yieldTo}
- namespace import ::tcl::unsupported::yieldTo
- proc pro {} {
- puts "creating producer"
- yield
- puts "producer starting"
- for {set i 0} {$i < 10} {incr i} {
- yieldTo consumer $i
- }
- puts "producer yielding end of stream"
- yieldTo consumer {}
- puts "producer returning"
- }
- proc con {} {
- puts "creating consumer"
- yield
- puts "consumer starting"
- while {[set i [yieldTo producer]] != {}} {
- puts $i
- }
- puts "consumer returning"
- }
- coroutine producer pro
- coroutine consumer con
- consumer
- coroutine producer pro
- coroutine consumer con
- 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.