Posted to tcl by aspect at Wed Jul 29 14:04:39 GMT 2015view raw

  1. # returns an unused procedure name
  2. proc gensym {prefix} {
  3. tailcall apply {{prefix} {
  4. string cat $prefix[llength [info commands $prefix*]]
  5. }} $prefix
  6. }
  7.  
  8. # creates an anonymous coroutine
  9. proc go {cmd args} {
  10. set name [gensym goro#]
  11. coroutine $name $cmd {*}$args
  12. return $name
  13. }
  14.  
  15.