Conflicting function names in separate toolboxes

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

Conflicting function names in separate toolboxes

babelproofreader
I have recently downloaded a toolbox to try out but find when I try using it
I get errors because the name(s) of some functions mirror those in a
different toolbox and I presume they are in conflict with regard to
inputs/outputs, e.g. the demo.m file calls a function called minFunc.m and
then errors and when I call help minFunc the help text returned in terminal
references a minFunc.m contained in a completely different toolbox.

Is there some way of temporarily prioritising a toolbox such that the
functions within it are called in preference to similarly named functions in
different toolboxes?



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: Conflicting function names in separate toolboxes

marco atzeri-2
On Wed, May 20, 2020 at 1:23 PM babelproofreader  wrote:

>
> I have recently downloaded a toolbox to try out but find when I try using it
> I get errors because the name(s) of some functions mirror those in a
> different toolbox and I presume they are in conflict with regard to
> inputs/outputs, e.g. the demo.m file calls a function called minFunc.m and
> then errors and when I call help minFunc the help text returned in terminal
> references a minFunc.m contained in a completely different toolbox.
>
> Is there some way of temporarily prioritising a toolbox such that the
> functions within it are called in preference to similarly named functions in
> different toolboxes?
>

unload the toolbox/package you are not using ?


Reply | Threaded
Open this post in threaded view
|

Re: Conflicting function names in separate toolboxes

mmuetzel
In reply to this post by babelproofreader
Am 20. Mai 2020 um 13:22 Uhr schrieb "babelproofreader":

> I have recently downloaded a toolbox to try out but find when I try using it
> I get errors because the name(s) of some functions mirror those in a
> different toolbox and I presume they are in conflict with regard to
> inputs/outputs, e.g. the demo.m file calls a function called minFunc.m and
> then errors and when I call help minFunc the help text returned in terminal
> references a minFunc.m contained in a completely different toolbox.
>
> Is there some way of temporarily prioritising a toolbox such that the
> functions within it are called in preference to similarly named functions in
> different toolboxes?

Octave looks for matching function names in the search path from top to bottom.
The functions of toolboxes whose path appears earlier in the search path have priority over those of toolboxes whose path appears later.
Usually the paths are added to the top of the search path when loading a package. So package that are loaded later might shadow functions of previously loaded packages.
Long story short: You can "prioritize" toolboxes by changing their load order.

HTH,
Markus


Reply | Threaded
Open this post in threaded view
|

Re: Conflicting function names in separate toolboxes

babelproofreader
In reply to this post by marco atzeri-2
marco atzeri-2 wrote

> On Wed, May 20, 2020 at 1:23 PM babelproofreader  wrote:
>>
>> I have recently downloaded a toolbox to try out but find when I try using
>> it
>> I get errors because the name(s) of some functions mirror those in a
>> different toolbox and I presume they are in conflict with regard to
>> inputs/outputs, e.g. the demo.m file calls a function called minFunc.m
>> and
>> then errors and when I call help minFunc the help text returned in
>> terminal
>> references a minFunc.m contained in a completely different toolbox.
>>
>> Is there some way of temporarily prioritising a toolbox such that the
>> functions within it are called in preference to similarly named functions
>> in
>> different toolboxes?
>>
>
> unload the toolbox/package you are not using ?

That would require editing my .octaverc file and then reverting the change,
which I would rather not do. I'd prefer a simple script/command line one
liner which would be much quicker and more convenient to implement.



--
Sent from: https://octave.1599824.n4.nabble.com/Octave-General-f1599825.html