Possible issue with disp and inputname

José Abílio Matos <[email protected]>
Newsgroups gmane.comp.gnu.octave.maintainers
Message-ID <3377447.hdfAi7Kttb@myth>
Hi,
  I have class where I would like to display the name of the variable in the 
disp method.

Something like (MWE):

classdef dispbug
    methods
        function obj=dispbug()
        end
        function disp(obj)
            disp(inputname(1))
        end
    end
end

Calling it I get:
>> format compact
>> xx = dispbug();
>> xx
xx =


>> disp(xx)
xx

As far as I understand what is going on this happens because when I call just 
xx it calls display(xx) that call disp probably as an expression. I am 
guessing and I could have looked into the code. :-)

Apparently this code works in matlab. I say apparently because I asked a 
colleague to test the full version and it works, I says something like:

>> xx
xx =
xx

If there is no assigned name then inputname returns ans.

This seems to be a a minor incompatibility with matlab.
While searching for similar bugs in savannah I found
https://savannah.gnu.org/bugs/?49794

although related this does not seem to be the same issue.

Should I report this to savannah?

Best regards,
-- 
José Matos
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.