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

XOTcl/NX mailing list by object move?

From: Koen Danckaert <koen_at_retarget.com>
Date: Mon, 20 Mar 2006 11:10:28 +0100

> Snit has a "myvar" method that returns the fully qualified name of a
> snit member variable. Perhaps something similiar (a method that
> returned a "reference" to an instance variable) would be useful in XOTcl?

I use the following two global procs for that:

    proc myproc {args} {linsert $args 0 [uplevel 1 self]}
    proc myvar {var} {return [uplevel 1 self]::$var}

The procs are global (not instprocs on "Object") because otherwise I would have to write "my myvar" or "my myproc". Now I can simply use them in the following way inside xotcl (inst)procs:

    button $x -command [myproc show 1 2 3]
    ...
    trace add variable [myvar status] write [myproc statusevent]
    ...
    vwait [myvar done]


(Note: in fact the "uplevel" in the definition of myproc/myvar is not even necessary. It seems that [self] always refers to the last Xotcl object on the callstack.)

Koen