help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Identifying the name of a parent function in a child function?


From: John W. Eaton
Subject: Re: Identifying the name of a parent function in a child function?
Date: Fri, 25 Apr 2008 10:34:34 -0400

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
| > address@hidden
| > 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]