[Xotcl] nextto
Gustaf Neumann
neumann at wu.ac.at
Fri Jan 23 23:56:53 CET 2015
Am 23.01.15 um 23:18 schrieb Victor Mayevski:
> Recently I looked over TclOO and noticed a "nextto" feature. It
> appears to be pretty useful and I supposed it should be trivial to
> implement it in NX. Any ideas how?
>
> Thanks,
>
> Victor
Dear Victor,
Such behavior can be achieved in nx via method handles, which are a
means to refer directly to specified methods. I would not recommend to
use such constructs in all programs, since this mechanism can break
certain contracts a programmer can otherwise rely on (e.g. mixin layers,
etc.).
The script below returns the following output
all the best
-g
::F.foo standard next
::E
::D
::C
::C DONE
::D DONE
::E DONE
::F.foo standard next DONE
===== handle = ::nsf::classes::D::foo
::D
::C
::C DONE
::D DONE
=======================================================
package require nx
nx::Class create C {
:public method foo {} {
puts [current class]; next puts "[current class] DONE"
}
}
nx::Class create D -superclass C {
:public method foo {} {
puts [current class]; next; puts "[current class] DONE"
}
}
nx::Class create E -superclass D {
:public method foo {} {
puts [current class]; next; puts "[current class] DONE"
}
}
nx::Class create F -superclass E {
:public method foo {} {
puts "[current class].foo standard next"
next
puts "[current class].foo standard next DONE"
set handle [D info method handle foo]
puts "===== handle = $handle"
: $handle
}
:create o1
}
o1 foo
=======================================================
More information about the Xotcl
mailing list