Posted to tcl by dgp at Fri Jan 16 16:50:20 GMT 2015view raw
- % package require Itcl 3
- 3.4
- % itcl::class Base {
- method do {args} {eval $args}
- method foo {} {bar}
- method bar {} {puts Base::bar}
- }
- % itcl::class Derived {
- inherit Base
- method bar {} {puts Derived::bar}
- }
- % proc bar {} {puts proc::bar}
- % Derived demo
- demo
- First we demo the expected "polymorphic" dispatch.
- An implicit "$this" is prepended to "bar" so we
- get the derived "bar" method called.
- % demo foo
- Derived::bar
- Then we demo that sticking an [eval] in the middle
- doesn't change that
- % demo do bar
- Derived::bar
- The builtin method "info" does the same -- we get the
- heritage info for the $this object.
- % demo info heritage
- ::Derived ::Base
- ***BUT!!!!*** if we stick an [eval] in the middle,
- things change!
- % demo do info heritage
- ::Base
- WTF!!!
- Itcl test info-4.3b insists this is the expected
- behavior, but that makes the info method bizarrely
- magical in suspending the rules applied to all
- other methods.
- Porting to Itcl 4 makes use of TclOO machinery, and trying to
- force this magic into that is leading to a royal mess!
- The attempts have broken other things.
- Someone please explain this nonsense.