Guidelines for Using upvar and uplevel

by Rob Mayoff

The Tcl upvar[upvar manual] and uplevel[uplevel manual] commands allow a procedure to modify the local variables of any procedure on the call stack. They are very powerful, and it is easy to use them to create code that is very hard to understand and maintain. This page contains some guidelines for using them. I posted the original version[Original version] of these guidelines to the AOLserver mailing list[AOLserver list archive].

Please send me[E-mail me] comments, corrections, and additions. Note that these are just guidelines; advanced Tcl programmers will occasionally have reason to violate them.

Guidelines for upvar

Guidelines for uplevel