Identifying the name of a parent function in a child function?
John W. Eaton
jwe at bevo.che.wisc.edu
Fri Apr 25 09:34:34 CDT 2008
On 25-Apr-2008, David Bateman wrote:
| Thomas Treichl wrote:
| > Hi,
| >
| > I'm currently playing with some algorithms and what I could need now that
| > would be a way to find out which, let's say, 'parent function' called my 'child
| > function'. Is there a way to do that by not passing an ID-variable from the
| > parent to the child (eg. like dbstack works in Matlab) and by not setting a
| > global or persistent variable before?
| >
| > What I mean by example
| >
| > function [] = funA ()
| > funC;
| > endfunction
| >
| > function [] = funB ()
| > funC;
| > endfunction
| >
| > function [] = funC ()
| > # Did funA or funB call me?
| > endfunction
| >
| > Thanks,
| >
| > Thomas
| > _______________________________________________
| > Help-octave mailing list
| > Help-octave at octave.org
| > https://www.cae.wisc.edu/mailman/listinfo/help-octave
| >
| >
| I would have thought that something like
|
| function y = funA (), y = funC; endfunction
| function y = funB (), y = funC; endfunction
| function y = funC (), y = evalin ("caller", "mfilename()"); endfunction
|
| should have worked, but it doesn't appear to.
I thought the same, but hey we are compatible with the other brand
here, though I don't think intentionally.
In any case, I've been working on some changes to improve the
backtrace error messages that will also make implementing dbstack
easy, so that should be in the development version soon. Sorry I
can't offer any other solution now.
jwe
More information about the Help-octave
mailing list