On 30/05/2016 17:34, Michael Keith wrote:
> What probably led me astray was that
> info object vars [self]
> returned_all_ variables: those from the base class as well as from
> the derived class.
It delivers (the names of) the variables in the object; they're just
variables in the object's instance namespace, nothing more. There's no
attempt to make variables defined by different classes separate, in part
because there are quite reasonable cases where you might want to have
subclasses and superclasses collaborating around a variable.
The only variables visible in a method (other than by the usual schemes
you use with a procedure) are those that you have asked for with the
[variables] *declaration* in the method's declaration scope. The
declaration scope of a method is its enclosing class (or the instance
for a pure instance method).
oo::class create Foo {
variable bar
method boo {} {
incr bar
}
}
The variable itself resides in the instance, but the request to make it
visible is in the class (as a directive to the variable resolution
engine, which is one of the deeply scary bits of Tcl's implementation).
Donal.
--
Donal Fellows — Tcl user, Tcl maintainer, TIP editor.