[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #58572] cellfun calls overloaded functions for
From: |
Markus Mützel |
Subject: |
[Octave-bug-tracker] [bug #58572] cellfun calls overloaded functions for class method isnumeric called instead of built-in isnumeric |
Date: |
Mon, 15 Jun 2020 15:11:25 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 |
Follow-up Comment #5, bug #58572 (project octave):
@jwe: That seems to be the case.
I modified "use_num" like this:
function rslt = use_num(obj)
fh = @isnumeric;
functions (fh)
fh(obj)
rslt = cellfun(fh, {'a_name'});
end
The result is:
>> ci = c_tst;
use_num_result = ci.use_num
ans =
struct with fields:
function: 'isnumeric'
type: 'classsimple'
file: 'MATLAB built-in function'
class: 'c_tst'
c_tst.isnumeric called
ans =
logical
1
use_num_result =
logical
0
And similarly for a function that isn't built-in:
classdef c2_tst
methods
function rslt = use_ff(obj)
fh = @fullfile;
functions (fh)
fh(obj)
rslt = cellfun(fh, {'a_name'});
end
function rslt = fullfile(obj)
disp('c2_tst.fullfile called');
rslt = true;
end
end
end
Results with Matlab R2020a:
>> res = c2.use_ff
ans =
struct with fields:
function: 'fullfile'
type: 'classsimple'
file: 'C:\Program
Files\MATLAB\R2020a\toolbox\matlab\iofun\fullfile.m'
class: 'c2_tst'
c2_tst.fullfile called
ans =
logical
1
Error using cellfun
Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.
Error in c2_tst/use_ff (line 7)
rslt = cellfun(fh, {'a_name'});
"file" seems to be where the function handle dispatches to if the input is
*not* the "class".
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?58572>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/