help-octave
[Top][All Lists]
Advanced

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

Re: Editing files, indexing operations...


From: Paul Kienzle
Subject: Re: Editing files, indexing operations...
Date: Mon, 23 Dec 2002 16:09:31 -0500
User-agent: Mutt/1.2.5.1i

On Mon, Dec 23, 2002 at 12:24:19PM -0800, James Frye wrote:
<snip>
> Unfortunately, ALL the analysis scripts are much the same: one main
> function that calls numerous other functions defined in the same file.
> (Which does to me seem the most reasonable way to do it, as you then don't
> have to worry about copying around dozens of separate .m files.)
> 
> So, is there an easy way to deal with this?  I would think other people
> might have encountered the same problem: anyone figure out what to do?

Placing 1; at the top of each file will cause unexpected results if two
m-files happen to have the same named internal function.  

You could simulate a namespace for the set of functions in which each 
internal function is tagged with the name of the externally visible 
function, and place each one in a separate file.  E.g., fn -> __f1__fn.  
So long as you change all references inside the list, this should work.
Note that you will have to replace @fn with "<tag>fn" if fn is one of
those functions.  You should not replace fn if it is in a comment.
There may also be some problems with eval, but these cases will be
rare.

E.g.,


test.m:

        % a meaningless example which overrides the builtin min fn
        function x=test2(a,b,c)
          z=min(a,min(b,c))*test2(c)

        function x=min(a,b,c)
          return b
            
        function y=test2(a,b)
          return min(a,b)

becomes

test.m:

        % a meaningless example which overrides the builtin min fn
        function x=test2(a,b,c)
          z=__test__min(a,__test__min(b,c))*__test__test2(c)

__test__min.m:

        function x=__test__min(a,b,c)
          return b

__test__test2.m:

        function y=test2(a,b)
          return __test__min(a,b)

This should be doable without too much effort in perl.  After editting,
rerun the m-split program and everything will be reloaded as usual.

Send me a copy once you get it done, and I can include it in octave-forge.

Paul Kienzle
address@hidden



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