bugGNU Octave - Bugs: bug #47755, Access to object arrays


bug #47755: Access to object arrays

Submitted by:  Guillaume <gyom>
Submitted on:  Thu 21 Apr 2016 04:26:34 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  Open
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Tue 16 Apr 2019 02:19:46 AM UTC, comment #8:

Desired is to be compatible with Matlab. Less a Roadmap, more a state of the art, is given in the wiki: https://wiki.octave.org/Classdef

What I can confirm is, that for the latest development release the original issue has not changed:

Kai Torben Ohlhus <siko1056>
Project Member
Mon 15 Apr 2019 07:32:19 AM UTC, comment #7:

Thanks for the reply. Can you verify that the first calling behaviour is the desired behaviour for Octave 6, and that the other syntaxes will have the same behaviour as the first?

Is there a roadmap for what the Octave 6 classdef behaviour will look like? For example MATLAB static method syntax is parsed but ignored, they act like instance methods but don't have the object passed in.

Peter Corke <petercorke>
Mon 15 Apr 2019 01:43:35 AM UTC, comment #6:

> Are these different behaviours desired/documented?

Certainly not. It is due to the fact, that classdef is not 100% Matlab compatible yet. Recently, jwe improved things a lot, but it consumes a lot of time. If you feel able to improve this for Octave 6, please don't hesitate to send us patches for this particular problem.

Otherwise you should stay with the first calling scheme to be compatible with both Octave and Matlab.

Kai Torben Ohlhus <siko1056>
Project Member
Sun 14 Apr 2019 03:10:38 AM UTC, comment #5:

Using Octave 5.1 these issues are still present, but this bug seems to be dormant.

In MATLAB these are all identical:


and the object array a is passed to the method myprop().

In Octave each behaves differently:

myprop(a) is called once and passed the object array a
a.myprop is called on every element of a, the return value is the concatenation of the return value from every call to my prop
a.myprop() always gives an error

error: can't perform indexing operation on array of my class objects

but not clear what it is trying to index. If an argument is given inside the parentheses it is passed to the method, so it's not using as an index for a. Octave certainly can perform indexing operations on this kind of object array, just not in this context.

Are these different behaviours desired/documented? I'm trying to make some code as compatible as possible between MATLAB and Octave, and it'd be good to know where I stand.

Peter Corke <petercorke>
Wed 29 Jun 2016 10:32:48 AM UTC, comment #4:

It never worked, I gave it an unsuitable item group. I think "Incorrect Result" fits better.

Kai Torben Ohlhus <siko1056>
Project Member
Wed 29 Jun 2016 10:11:27 AM UTC, comment #3:

This is tagged as a "regression". What version did it work in?

Lachlan Andrew <lachlan>
Mon 25 Apr 2016 02:31:17 PM UTC, comment #2:

I can confirm the output of the original post and #1. Furthermore it should return the vector [1, 2] in any case.

The Octave's classdef implementation seems to be close to the behavior of a struct.

Matlab produces:

Octave produces:

Kai Torben Ohlhus <siko1056>
Project Member
Thu 21 Apr 2016 05:06:32 PM UTC, comment #1:

To be more precise, here is what happens with different syntax calls:

Guillaume <gyom>
Thu 21 Apr 2016 04:26:34 PM UTC, original submission:

Given a class like this:

create an object array:

A call to myprop() property should return [1 2] but instead it returns:

Guillaume <gyom>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by petercorke (Posted a comment)
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-06-29 siko1056 Item GroupRegression => Incorrect Result
    2016-04-25 siko1056 CategoryNone => Interpreter
        Item GroupNone => Regression
        StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.4