View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] nextto

From: Gustaf Neumann <neumann_at_wu.ac.at>
Date: Fri, 23 Jan 2015 23:56:53 +0100

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
=======================================================