octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #47763] load: function handle to user function


From: Guillaume
Subject: [Octave-bug-tracker] [bug #47763] load: function handle to user function uses full path, should just search load path
Date: Mon, 25 Apr 2016 11:06:17 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0

Follow-up Comment #6, bug #47763 (project octave):

Thanks again, Mike. Here is an example where the full path is used when there
is an "ambiguity"; myfoo() is available twice in the search path (either
displaying 'foo1' or 'foo2'):


>> addpath /tmp/foo1
>> myfoo()
foo1
>> address@hidden;
>> addpath /tmp/foo2
>> myfoo()
foo2
>> f()
foo1
>> save foo.mat f
>> clear f; load foo.mat
>> f()
foo1
>> rmpath /tmp/foo1
>> clear f; load foo.mat
>> f()
foo2


So the behavior when loading a function handle from a mat-file seems to be:
* if there is a function corresponding to the full path and that path is in
the search path, create a function handle to it
* otherwise, ignore the full path and create a function handle to the first
function with that name in the search path if it exists
* if it doesn't exist, create a function handle without warning to a
nonexisting function with that name (a call to foo() returns "Undefined
function or variable 'myfoo'.") and use the first function in the search path
when one becomes available:


>> rmpath /tmp/foo1
>> rmpath /tmp/foo2
>> clear f; load foo.mat
>> functions(f)
ans = 
    function: 'myfoo'
        type: 'simple'
        file: ''
>> f()
Undefined function or variable 'myfoo'.
>> addpath /tmp/foo1
>> f()              
foo1
>> addpath /tmp/foo2
>> f()              
foo2


The last part is less important and related to this "won't fix" bug #31821

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?47763>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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