I need to know if the current procedural context is inside a method (isntproc, proc, whatever) or not. 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]. Besides, I've never been fond of having to resort to error- catching to find out information (a bit like how people used to test for the existence of an array element with [catch]).
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.
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
"self" can be used to check whether the xotcl callstack is non-empty.
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.
-gustaf
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 neater.