Posted to tcl by aspect at Wed Nov 30 03:33:40 GMT 2011view pretty

Variable resolution
-------------------
Unlike the variable command in Tcl, the variable command in Jim Tcl
is an identical analog to the global command. The variable command
creates a link from a local variable to a namespace variable.

**
Invoked with two arguments, it also sets the value of the linked variable.

namespace eval ::test {
  variable myvar 4
}
**


For example, the following procedure uses 'variable' to access myvar.

proc ::test::myproc {} {
  variable myvar
  incr myvar
}

Note that there is no automatic resolution of namespace variables.
For example, the following will *not* work.

namespace eval ::test {
  variable myvar 4
}
namespace eval ::test {
  # This will increment a local variable, not ::test::myvar
  incr myvar
}

In the same way that variable resolution does not "fall back" to
global variables, it also does not "fall back" to namespace variables.