[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a built-in variable that contains a function's name?
From: |
Paul Kienzle |
Subject: |
Re: Is there a built-in variable that contains a function's name? |
Date: |
Mon, 31 Dec 2001 09:23:17 -0500 |
Sort of. You could write an oct-file which returns the function name
given in the global variable curr_function. Something like the following:
/* This program is granted to the public domain */
#include <octave/oct.h>
#include <octave/ov-usr-fcn.h>
#include <octave/toplev.h>
DEFUN_DLD(fname,args,nargout,"\
fname returns the name of the currently executing user function\n\
")
{
octave_value_list retval;
if (curr_function)
retval(0) = curr_function->function_name ();
else
error("fname: there is no currently executing function");
return retval;
}
Paul Kienzle
address@hidden
On Sat, Dec 29, 2001 at 11:13:12PM -0300, Roberto Hernandez wrote:
> Hello everyone,
>
> Is there any built in variable (such as nargin) that contains the name
> of the function that is being executed? I've been searching the
> documentation, but if it's there I haven't found it.
>
> What I'm trying to do is to include something like this at the beginning
> of each function:
>
> --------------------
> function foo()
> printf("%s\n", variable_containing_function_name);
> fflush(stdout);
>
> ...
> endfunction
> --------------------
>
> That way I can locate bugs a lot easier. I would rather use a variable
> than hard code the name in the printf statement if that's possible, just
> in case I later change the function name and forget to change the rest.
>
> TIA and Happy New Year.
>
> - Roberto
>
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
>
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------