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

David Bateman David.Bateman at motorola.com
Fri Apr 25 02:33:06 CDT 2008


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.

D.




-- 
David Bateman                                David.Bateman at motorola.com
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



More information about the Help-octave mailing list