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

    try {
	while {[llength [set var [$coro]]] != 0} {
	    try {
		uplevel 1 $script
	    } on error {message options} {
		dict incr $options -level 1
		return -options $options $message
	    } on return {retval options} {
		dict incr $options -level 1
		return -options $options $retval
	    } on break {} {
		break
	    } on continue {} {
		continue
	    }
	}
    } finally {
	if {[namespace which $coro] ne {}} {
	    rename $coro {}
	}
    }