Posted to tcl by kap at Sun Aug 09 18:25:50 GMT 2015view raw

  1.  
  2. namespace eval foo {
  3.  
  4. proc foo {foo} {
  5. return $foo
  6. }
  7.  
  8. oo::class create bar {
  9.  
  10. variable Bar
  11.  
  12. constructor {bar} {
  13. my bar $bar
  14. # Is there any way to have [my bar] evaluated with
  15. # Each call of the forward method foo?
  16. oo::objdefine [self] forward foo foo::foo my bar
  17. }
  18.  
  19. method bar {{bar {}}} {
  20. if {$bar ne {}} {
  21. set Bar $bar
  22. }
  23. return $Bar
  24. }
  25. }
  26. }
  27.  
  28. foo::bar create a HELLO
  29.  
  30. # Fails due to the args "my" and "bar" being sent to [foo::foo]
  31. a foo