Fri 11 Aug 2017 03:26:04 PM UTC, comment #10:
This was a simple fix. Unlike other data types, the struct do_index_op function was not checking the length of the index list for the special case where it was 0 (empty). I changed that and added a test for it here http://hg.savannah.gnu.org/hgweb/octave/rev/1b232c0c19e6.
I also checked the other data types and they seem to work, except possibly for objects where the subsref routine is often overloaded. I'll ask a question about that on the Maintainer's list.
|
Mon 07 Aug 2017 03:51:53 PM UTC, comment #9:
Marking as confirmed. The issue seems to be that an empty indexing expression for structs is interpreted as indexing with a null array.
Sample Code:
Conversely, for Arrays no index expression means perform no indexing operation at all.
|
Wed 02 Aug 2017 06:31:34 PM UTC, comment #8:
for reference, Matlab 2017 output for Dan's comment #6:
|
Tue 01 Aug 2017 10:26:17 PM UTC, comment #7:
jwe: I'm sorry my reponse wasn't more precise.
I agree with Dan Sebald 'x()' should be the same as 'x'.
To be more precise we have:
So in Matlab assert passes and:
in Octave it fails and:
|
Tue 01 Aug 2017 07:09:59 PM UTC, comment #6:
It sounds to me like x() should always be the same as plain x. In Octave,
In the vector case, 'a()' is the same as 'a'... not 'a(1)'. So for consistency, I would think that 'b()' should print out whatever 'b' prints out--which isn't necessarily the same as what 'b(1)' prints out.
|
Tue 01 Aug 2017 06:51:45 PM UTC, comment #5:
Sorry, I'm just really confused now by the description of what Matlab is doing.
|
Tue 01 Aug 2017 12:33:41 AM UTC, comment #4:
It is true of double, char, int32, classdef. So
All work, both in Matlab and in Octave. As far as I can tell only struct doesn't.
|
Mon 31 Jul 2017 11:24:06 PM UTC, comment #3:
Is this true of all structs or just scalar structs?
Is this true of all scalar objects?
|
Mon 31 Jul 2017 08:45:01 PM UTC, comment #2:
I mean that for Matlab the code would execute fine. What I meant by the equivalency is that:
for Matlab.
And for Octave it isn't, as your example clearly shows.
|
Mon 31 Jul 2017 08:33:57 PM UTC, comment #1:
I'm not following what is meant by "For Matlab it is equivalent to a(1)". "a()" in Octave is the same as "a(1)" in Matlab? Is the following what you mean?
|
Mon 31 Jul 2017 07:05:59 PM UTC, original submission:
I apologize if this has been submitted earlier, I couldn't find it.
So with this code:
Returns
For Matlab it is equivalent to:
This might seem trivial in most cases, but if you had a class name 'class1' and property name 'prop1'. If 'prop1' happens to be a struct your (somewhat improper) code:
Fails when you try to assign something to a field of that struct.
Should I try to fix this, or is the code example I gave just "bad coding" and it's better if the code doesn't execute?
|