[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #65116] classdef display override populates an
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname |
Date: |
Fri, 5 Jan 2024 14:22:44 -0500 (EST) |
Update of bug#65116 (group octave):
Status: None => Patch Reviewed
_______________________________________________________
Follow-up Comment #6:
I reviewed the patch and it works for the issue of this bug report, and it
passes all of the existing inputname() tests.
One thing I note is that the m-file had a FIXME note with three test cases.
## FIXME: Actually, it probably *isn't* worth fixing, but there are small
## differences between Octave and Matlab.
##
## 1) When called from the top-level or a script, Matlab throws an error
##
## inputname (1) % at command prompt
## % Octave returns "", Matlab throws an error
##
## 2) cell or struct indexing causes all further names to be returned as ""
##
## c = {'a', 'b'}
## y = 1; z = 2;
## fcn (c, y, z)
## % inputname() would return 'c', 'y', 'z' for the inputs.
## fcn (c{1}, y, z)
## % inputname() would return '', '', '' for the inputs.
##
## 3) If inputname is not called from a function, Matlab walks up the stack
## until it finds some valid code and then works from there. This could
## be relevant for mex files or anonymous functions.
##
## f = @(x) inputname (x);
## a = 1:4;
## arrayfun (fn, a, 'uniformoutput', false)
## % output is {'fn', 'a', '', ''}
I verified that Matlab does the same thing as Octave for case #2 so that
difference is no longer true.
For item #1, I think it would be better to throw an error at the first
opportunity when a programmer is using a function incorrectly. The
alternative is that an error is eventually found downstream of the actual
source of the problem and it takes a long time to trace it back to the source.
This seems like it might be easier to implement now that the code is in C++.
Can't we know whether we are in a function context, or not, and thus whether
to emit an error? I'm thinking of the function is_user_fcn_frame() for
example.
I'm less concerned about item #3. The inputname() function seems more useful
in true functions rather than anonymous function handles. Still, maybe there
is a way to simply implement this? If not, I think we should still leave a
note in the code about the difference between Octave and Matlab.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?65116>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans whith class when using inputname, John Donoghue, 2024/01/03
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans whith class when using inputname, John Donoghue, 2024/01/04
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname, Rik, 2024/01/04
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname, Rik, 2024/01/04
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname, John W. Eaton, 2024/01/04
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname, Rik, 2024/01/04
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname, Rik, 2024/01/04
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname, John W. Eaton, 2024/01/05
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname,
Rik <=
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname, John Donoghue, 2024/01/05
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname, John W. Eaton, 2024/01/05
- [Octave-bug-tracker] [bug #65116] classdef display override populates ans with class when using inputname, Rik, 2024/01/05