Posted to tcl by colin at Mon May 24 09:16:47 GMT 2010view raw

  1. Nub domain /coco/ Coco lambda {r {
  2. set r [yield] ;# initially just redirect to this coroutine
  3. while {1} {
  4. # this coroutine loops around counting calls in $n
  5. set content [<h1> "Coco - Coroutining"]
  6. append content [<p> "You have called the coroutine [incr n] times."]
  7. set r [yield [Http Ok [Http NoCache $r] $content]]
  8. }
  9. }}