wrapper functions

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

wrapper functions

Corbin Champion
How in octave can 2 functions of the same name be distinguished when they
are called?  Here are a couple of cases of interest:
a) there are 2 function.m files with the same name and both in the path, but
I want to do one of them specifically.
say I want to call use function.m (a) from within function.m (b).  Is there
a way to may this happen?
b) how about the case where version (a) is a builtin function?
Thanks in advance,
Corbin




-------------------------------------------------------------
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 | Threaded
Open this post in threaded view
|

RE: wrapper functions

Corbin Champion

I see the function builtin achieves this when from a function.m I want to
call the builtin function called 'function'.  I haven't figured out the a)
example yet though.  Any help with that would be great.
Thanks,
Corbin

>From: "Corbin Champion" <[hidden email]>
>To: [hidden email]
>Subject: wrapper functions
>Date: Mon, 27 Mar 2006 22:28:46 +0000
>
>How in octave can 2 functions of the same name be distinguished when they
>are called?  Here are a couple of cases of interest:
>a) there are 2 function.m files with the same name and both in the path,
>but I want to do one of them specifically.
>say I want to call use function.m (a) from within function.m (b).  Is there
>a way to may this happen?
>b) how about the case where version (a) is a builtin function?
>Thanks in advance,
>Corbin
>
>
>
>
>-------------------------------------------------------------
>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 | Threaded
Open this post in threaded view
|

Re: wrapper functions

Stéfan van der Walt
On Mon, Mar 27, 2006 at 11:52:08PM +0000, Corbin Champion wrote:
>
> I see the function builtin achieves this when from a function.m I want to
> call the builtin function called 'function'.  I haven't figured out the a)
> example yet though.  Any help with that would be great.

I have a directory f1 and f2, both containing a function named "f".  I
can then do

octave:1> source "f1/f.m"
octave:2> f
1
octave:3> f1 = @f
f1 =

f

octave:4> source "f2/f.m"
octave:5> feval(f1)
1
octave:6> f
2

Regards
Stéfan



-------------------------------------------------------------
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 | Threaded
Open this post in threaded view
|

Re: wrapper functions

Bill Denney
In reply to this post by Corbin Champion
On Mon, 27 Mar 2006, Corbin Champion wrote:

> How in octave can 2 functions of the same name be distinguished when
> they are called?  Here are a couple of cases of interest:

Generally, this is not good style.  Often, the best idea is to just name
them differently.

I see from your next message that you found the builtin function.  You
should be able to use it something like

[outputs] = builtin('functionname', 'arg1', 'arg2', ...)

Bill

--
"My wife doesn't like it when I eat potentially life-threatening stuff.
I don't know what her problem is."
   -- Steve, http://www.thesneeze.com/mt-archives/000115.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
-------------------------------------------------------------