How to detect the completion of a Tcl coroutine?
问题 I'd like to find a nice way in Tcl to detect the end of a coroutine. Consider: coroutine cor apply {{} { yield 1 yield 2 yield 3 }} try { puts [cor] puts [cor] puts [cor] puts [cor] } trap {TCL LOOKUP COMMAND cor} {e} { puts "done" } This works, but it feels like a hack and it is brittle. If I rename cor and forget to rename it in the trap, it fails. If I leave out the cor in the trap, it will catch unrelated typos. There's got to be a better way. What is it? 回答1: To detect if a command still