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

  1. package require TclOO
  2. namespace import oo::*
  3.  
  4. class create Vartest {
  5. variable v3
  6. variable v1 v2
  7.  
  8. method moop {v} {
  9. puts stderr "moop $v [set $v]"
  10. }
  11. method woo {} {
  12. my moop v1
  13. my moop v2
  14. my moop v3
  15. }
  16. constructor {} {
  17. set v1 1
  18. set v2 1
  19. set v3 1
  20. }
  21. }
  22.  
  23. Vartest create test
  24. test woo
  25.  
  26. ----
  27. tclsh8.6 tcloo.tcl
  28. moop v1 1
  29. moop v2 1
  30. can't read "v3": no such variable
  31. while executing
  32. "set $v"
  33. (class "::Vartest" method "moop" line 2)
  34. invoked from within
  35. "my moop v3"
  36. (class "::Vartest" method "woo" line 4)
  37. invoked from within
  38. "test woo"
  39. (file "tcloo.tcl" line 24)
  40.