[Xotcl] Testing for execution inside object

Kristoffer Lawson setok at fishpool.com
Tue Oct 3 16:43:49 CEST 2006

On 3 Oct 2006, at 14:55, Gustaf Neumann wrote:

> Kristoffer Lawson schrieb:
>> I need to know if the current procedural context is inside a  
>> method (isntproc, proc, whatever) or not.
> can you explain in more detail, what the problem is?
> Note, that one can calls tcl procs from within xotcl methods, one  
> can have evals, uplevels, etc.

I have a debug library that automatically displays information about  
the proc or method in which it was called, to get the context for the  
information. I want to check that if I'm running in an XOTcl method,  
I also want to display the class for it.

>> What is the best way to do this? I used [self] to check by  
>> catching the error, but that doesn't work particularly well if  
>> another package happens to define the command [self].
> use ::xotcl::self

Good idea.

> "self" can be used to check whether the xotcl callstack is non-empty.

Yes, but only by wrapping it in a [catch].

> without promising to much, a sucommand"ismethod" for "self"  
> retuning 0 or 1 depending whether the
> current stackframe is an xotcl method should be doable with little  
> effort.

Worth considering. It's not perhaps high-priority, but might make it  

            /  http://www.fishpool.com/~setok/

More information about the Xotcl mailing list