Posted to tcl by colin at Mon Jan 12 02:19:19 GMT 2009view pretty

package require TclOO
namespace import oo::*

class create Vartest {
    variable v3
    variable v1 v2

    method moop {v} {
	puts stderr "moop $v [set $v]"
    }
    method woo {} {
	my moop v1
	my moop v2
	my moop v3
    }
    constructor {} {
	set v1 1
	set v2 1
	set v3 1
    }
}

Vartest create test
test woo

----
tclsh8.6 tcloo.tcl
moop v1 1
moop v2 1
can't read "v3": no such variable
    while executing
"set $v"
    (class "::Vartest" method "moop" line 2)
    invoked from within
"my moop v3"
    (class "::Vartest" method "woo" line 4)
    invoked from within
"test woo"
    (file "tcloo.tcl" line 24)