help-octave
[Top][All Lists]
Advanced

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

Re: same function name in two files


From: kamaraju kusumanchi
Subject: Re: same function name in two files
Date: Sun, 15 Jun 2014 20:38:11 -0400


On Sun, Jun 15, 2014 at 8:27 PM, Ben Abbott <address@hidden> wrote:

On Jun 15, 2014, at 8:06 PM, kamaraju kusumanchi <address@hidden> wrote:

> Let's say I have two scripts (fileA.m, fileB.m) with the following set of functions.
>
> fileA.m
> foo()
> funcA1()
> funcA2()
>
> fileB.m
> foo()
> funcB1()
> funcB2()
>
> The implementation of foo() in both files is completely different. I have no write permissions to edit fileA.m, fileB.m
>
> A third script (fileC.m) uses all the six functions. I want to call both foo() implementations at different points in the code. Is there any way to achieve that? For example, is there anything like fileA.foo() , fileB.foo() to distinguish between the two?
>

I assume fileA.m and fileB.m are scripts and not functions?
 
Yes, all three of them fileA.m, fileB.m and fileC.m are scripts and not functions. 
 

Then, first run fileA and when you use foo() it corresponds to the implementation in fileA.

        fileA
        foo

To use the version if fileB, first fun fileB

        fileA
        foo


IMHO, this is really error prone way of doing it. Since every time you write code, you have to look back, keep track of the function octave is going to pick up. I am surprised octave does not have better namespace capabilities.

raju
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/

reply via email to

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