Posted to tcl by dgp at Thu Jul 13 20:01:05 GMT 2017view raw

  1. % oo::class create B {
  2. variable b
  3. constructor {} {set b 2}
  4. }
  5. ::B
  6. % oo::class create D {
  7. superclass B
  8. method foo {} {
  9. puts "b is $b ([namespace which -variable b] in [namespace current])"
  10. }
  11. }
  12. ::D
  13. % D create d
  14. ::d
  15. % d foo
  16. can't read "b": no such variable
  17.