help-octave
[Top][All Lists]
Advanced

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

Re: invoke overwritten functions


From: ernst
Subject: Re: invoke overwritten functions
Date: Sun, 27 Jan 2013 23:40:10 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120825 Thunderbird/15.0

Hi Jordi,

now i start understanding:
if there is a function a on the loadpath invoking another function b,
later on the loadpath,
then i can e.g. add another entry to the loadpath pointing to another
function b
overwriting the old function b.
Now this one will be used also in a.

So function a is broken.

I think, people overwrite function b only for use in further functions c
defined even later in the loadpath.
So if a function in the loadpath is evaluated, for further functions
should be searched only in later segments in the loadpath.

Is this realistic??

Are there approaches to solve the problem???

greetings,

Ernst
> Hi Jordi,
>
>> On 25 January 2013 11:22, ernst <address@hidden> wrote:
>>> I have the problem that i need to invoke overwritten functions.
>>> Even worse, i want do invoke the overwritten function from within the
>>> overwriting function.
>> Matlab has a huge namespace problem:
>>
>>     http://abandonmatlab.wordpress.com/category/my-kingdom-for-a-namespace/
> ah, I see.
> The article is very interesting.
> In particular, that "which -all message" can be used to find all files
> defining message.
> These seem *all* oct/mex and also all m-files which may define the
> function message.
> Also these files come in the ordering in which one overwrites the next.
> But if i try this to octave, only the last function is displayed.
> Is this a bug?
> The behavior described for matlab would solve part of my problem.
>
> Also if i try type for a function defined by an mfile,
> this mfile is displayed literally.
> Seems also not as in documentation.
>
>
> What I am also interested in is whether it is possible to run an mfile
> directly
> like a script can be run by source.
> If so, how can i pass a parameter?
>
> The combination of 'which -all <functionname>' and direct invocation
> would solve my problem.
>
> Your suggestion using object orientation, is what i normally do.
> I want to provide a mechanism to inject various kinds of number types
> into octave
> using a uniform wrapper class in octave.
>
> But: This does not work for functions with empty parameter list.
> E.g. I want to use rand() (defined as octfile) to define my own random
> function rand()
> which of course must use rand() in octave.
>
> greetings,
>
> ernst
>> Octave has to mimic this problem. There is no simple solution for you.
>> The only advice I an offer is to not clobber the namespace.
>>
>> For your particular case, depending on what you're doing, it sounds
>> like you want something like polymorphism. You can use old-style
>> classes to accomplish this:
>>
>>     
>> http://www.gnu.org/software/octave/doc/interpreter/Function-Overloading.html
>>
>> Sorry,
>> - Jordi G. H.
>>
>



reply via email to

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