help-octave
[Top][All Lists]
Advanced

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

Re: Finding out the name of the dispatched function


From: Shai Ayal
Subject: Re: Finding out the name of the dispatched function
Date: Sun, 16 Apr 2006 08:49:07 +0300
User-agent: Thunderbird 1.5 (Windows/20051201)

My question was not clear -- consider the following example with the theoretical function HowWasICalled:

function xxx
   disp(["--> ",HowWasICalled()]);
endfunction

dispatch("yyy","xxx","any");
dispatch("zzz","xxx","any");

xxx
--> xxx

yyy
--> yyy

zzz
--> zzz


Is the a function which does what HowWasICalled does? A function like this would allow a single function to be reused. An immediate example which springs to mind is a generic warning function:

function gen_warn
   warning("%s is depreciated\n",HowWasICalled());
endfunction

dispatch("set","gen_warn","any");
dispatch("gset","gen_warn","any");


and so on

Shai

Paul Kienzle wrote:
Help dispatch says:


    dispatch('f')

      List dispatch functions for 'f'

This doesn't quite do what you want.

Unfortunately dispatch('f','type') clears the dispatch rather than
displaying it.  This could be changed to display so that
dispatch('f','type') displays the dispatch, and use something else
such as dispatch('f','type',[]) to clear it.

- Paul

On Apr 15, 2006, at 2:41 PM, Shai Ayal wrote:

Hi all,

Is there a way to find out the name of the dispatched function? An example:

function xxx
   disp("xxx")
endfunction

dispatch("yyy","xxx","any");
dispatch("zzz","xxx","any");

I would like to know in xxx whether it was called as xxx, yyy, or zzz.

Shai



-------------------------------------------------------------
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
-------------------------------------------------------------





-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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