Version 0 of corovars

Updated 2009-03-01 22:58:23 by CMcC

Variables declared within the main body of a coroutine persist for the life of the coroutine. This much is obvious. What may be less obvious is that you can access those variables from commands called from the coro, using [upvar #1], so here's a little wrapper to facilitate that:

    proc corovars {args} {
        foreach n $args {lappend v $n $n}
        uplevel 1 [list upvar #1 {*}$v]
    }

So, coro-persistent variables may be declared thus within procs:

    corovars x y z

enter categories here