octave-maintainers
[Top][All Lists]
Advanced

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

Re: Need test run in Matlab


From: Burgers, A.R. (Teun)
Subject: Re: Need test run in Matlab
Date: Thu, 19 Dec 2019 08:47:38 +0100
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

Op 19-12-2019 om 00:30 schreef John W. Eaton:
On 12/18/19 2:53 PM, Burgers, A.R. (Teun) wrote:
Op 18-12-2019 om 18:51 schreef John W. Eaton:
On 12/18/19 12:37 PM, John W. Eaton wrote:
On 12/18/19 10:11 AM, Juan Pablo Carbajal wrote:

These are the results

Thanks.

after I modified f1 and f2 (attached; Matlab
2019a doesn't  accept declaration of persistent and initialization in
the same line)

Oops.

It looks like the private function is loaded the first time it is used and then also cleared by the "clear functions" command.  But then it also remains available through the handle.  So I'm wondering whether the handle should retain a reference to the function and "clear functions" should only remove it from thh symbol table, or whether it should be reloaded if it becomes invalid.  I'm thinking the first option would be best unless someone knows of a reason to do otherwise.

Here's another test to run to see whether keeping a reference to the function in the handle will be compatible with Matlab behavior: unpack the attached file and execute the following commands in Matlab:

cd fh-bug
fh = f1
fh()         %% should display "foo-i-hithere: 1"
f2           %% should display "foo-i-hithere: 2"
clear functions   %% what will happen with persistent value in "gg"?
fh()         %% does this display "... 3" or "... 1"?
f2           %% does this display "... 1" or "... 2" or ?

jwe

I get this:

 >> version
ans = '9.5.0.1049112 (R2018b) Update 3'

 >> cd fh-bug
 >> fh = f1

fh =  function_handle with value:    @gg

 >> fh()
foo-i-hithere: 1
 >> f2
foo-i-hithere: 2
 >> clear functions
 >> fh()
foo-i-hithere: 1
 >> f2
foo-i-hithere: 2

Thanks.

So it looks like "clear functions" also clears functions that are referenced by function handles, but then those handles are able to reload them from their initial location, even if that is no longer in the search path (as shown by the first tests I posted earlier).  Does that seem like the correct interpretation?  To be sure, does the above work the same if you do

   cd fh-bug
   fh = f1
   fh()
   f2
   cd ..
   clear functions
   fh()  %% does this still work?
   f2  %% expect error here as f2 is no longer in the search path

jwe

In that scenario I get this. Also the response after the last f2 command is not immediate, the search for f2 takes some time, probably because of network locations in the path.

>> cd fh-bug
>> fh=f1

fh =  function_handle with value:   @gg

>> fh()
foo-i-hithere: 1
>> f2
foo-i-hithere: 2
>> cd ..
>> clear functions
>> fh()
foo-i-hithere: 1
>> f2
'f2' is not found in the current folder or on the MATLAB path, but exists in:
    C:\tmp\tmp\fh-bug

Change the MATLAB current folder or add its folder to the MATLAB path.

>>





reply via email to

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