package require TclOO namespace import oo::* proc foo n { set obj [object new] objdefine $obj method init {_n} {my variable n; set n $_n} objdefine $obj method acc i {my variable n; incr n $i} $obj init $n list ::apply [list i [subst -novariables {[set obj] acc $i}]] } proc destroy_acc acc { [lindex $acc 1 1 0] destroy }