Posted to tcl by pooryorick at Wed Apr 20 13:51:28 GMT 2016view raw
- #! /bin/env tclsh
- proc r {} {
- set name [info cmdcount]
- namespace eval $name {
- namespace export *
- namespace ensemble create
- proc finalize {id} {
- }
- proc initialize {id spec} {
- return {finalize initialize read watch}
- }
- proc read {id count} {
- after 0 [list after idle [list [info coroutine]]]
- yield
- return hello\n
- }
- proc watch {id spec} {
- }
- }
- return $name
- }
- after 0 [list coroutine main apply {{argv0 argv} {
- set r1 [r]
- set chan [chan create read $r1]
- gets $chan line
- puts $line
- }} $argv0 $argv]
- vwait forever