Posted to tcl by kbk at Mon Dec 16 17:35:42 GMT 2013view raw

  1. try {
  2. while {[llength [set var [$coro]]] != 0} {
  3. try {
  4. uplevel 1 $script
  5. } on error {message options} {
  6. dict incr $options -level 1
  7. return -options $options $message
  8. } on return {retval options} {
  9. dict incr $options -level 1
  10. return -options $options $retval
  11. } on break {} {
  12. break
  13. } on continue {} {
  14. continue
  15. }
  16. }
  17. } finally {
  18. if {[namespace which $coro] ne {}} {
  19. rename $coro {}
  20. }
  21. }