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

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

[Octave-bug-tracker] [bug #59451] Function handles become invalid if pat


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #59451] Function handles become invalid if path to function is removed
Date: Fri, 13 Nov 2020 02:05:33 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36 Edg/86.0.622.63

Follow-up Comment #8, bug #59451 (project octave):

Some tests with Matlab R2020b:
I created two folders "a" and "b". Both of them contain a function file
"fcn.m" which displays a string to distinguish them.
1. In the main folder containing the folders "a" and "b" (where no function
file named "fcn.m" is in the path), I ran the following:

>> hf = @fcn
hf =
  function_handle with value:
    @fcn
>> cd a
>> hf()
This is "a".
>> cd ../b
>> hf()
This is "b".


2. Creating the function handle when inside folder "a":

>> hf = @fcn
hf =
  function_handle with value:
    @fcn
>> hf()
This is "a".
>> cd ../b
>> hf()
This is "a".


3. The same as 2. but don't call the function handle before cd-ing to the
other folder:

>> hf = @fcn
hf =
  function_handle with value:
    @fcn
>> cd ../b
>> hf()
This is "a".


So it looks like if a function handle is created "lazy" it will always be lazy
(and never "fix" to a certain function). If a function handle can be resolved
on creation, it will always refer to that function.

I'm not sure I understand comments #5 through #7. But I'm happy to run tests.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59451>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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