Hi everyone,
Is there any way to find out which object [instance] is calling some function? I expected that this_object() will do the work, but regardless of the caller it always returns module where it is written. Actually, what I need is to get exact reference to the instance of the object which calls my function (if there is an instance).
backtrace() won't work - I'll get the function name and location in the file, but no reference to calling object...
Or, to summarize:
--- snip otest.pike --- class A { void method() { some_func(); } }
some_func() { write(sprintf("Called from: %O", caller())); }
int main() { A a = A(); some_func(); // Should print "Called from: otest()" a->some_func(); // Should print "Called from: A()" and (caller() == a) will be true }
--- snip otest.pike ---
Regards, /Al