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

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

[Octave-bug-tracker] [bug #48802] function overload resolution on functi


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #48802] function overload resolution on function handles fails on classdef methods defined in class body
Date: Thu, 7 Feb 2019 14:52:06 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

Follow-up Comment #3, bug #48802 (project octave):

I'm a bit confused by the statement in the Matlab docs that is quoted in the
original submission.  What is meant by "if the function you specify overloads
a function in a class that is not a fundamental Matlab class"?  What is a
"fundamental Matlab class"?  Is that a type like in32 or double or struct, or
any class that is distributed as a part of Matlab, or what?

I think I may need some more examples to understand how things are expected to
work.

What is supposed to happen for the following


% c1.m:

classdef c1
  methods
    function m1 (obj)
      disp ('c1:m1');
    end
  end
end

% c2.m:

classdef c2
  methods
    function m1 (obj)
      disp ('c2:m1');
    end
    function sin (obj)
      disp ('c2:sin');
    function fh = m1_h (obj)
      fh = @m1;  %% Does this always bind to c2:m1
                 %% or can lookup rules result in a
                 %% call to another function if arg
                 %% is not c2 object?
    end
    function fh = sin_h (obj)
      fh = @sin;
    end
  end
end

% m1.h:

function m1 (x)
  disp ('m1');
  disp (x);
end

% code:

c1_obj = c1 ();
c2_obj = c2 ();
m1_fh = c2.m1_h ();
sin_fh = c2.sin_h ();

m1_fh (pi)  %% m1 or error from c2:m1 about wrong type?
m1_fh (c2_obj)  %% c2:m1, I assume
m1_fh (c1_obj)  %% c1:m1, or error from c2:m1 about wrong type?

sin_fh (pi)  %% built-in sin or error from c2:sin about wrong type?
sin_fh (c2_obj)  %% c2:sin, I assume

fh = @sin;
fh (pi)      %% built-in sin, I assume.
fh (c2_obj)  %% c2:sin or error from built-in sin about wrong type?


I guess my question is, precisely when is binding deferred?


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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