bugGNU Octave - Bugs: bug #55767, classdef property should not be...


bug #55767: classdef property should not be the same as classdef name (at least for Matlab compatibility)

Submitter:  Rik <rik5>
Submitted:  Fri 22 Feb 2019 09:59:01 PM UTC
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  Matlab Compatibility
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Thu 18 Apr 2019 10:39:18 PM UTC, comment #2: 

I was just pointing out what Matlab does, not that we need to follow them.

However, from a coding/confusion perspective would it make sense not to have the same name for two different things?  I like Perl, but one of the dings against it is that there is almost nothing to prevet you from coding really bad, unintelligible, unmaintainable code.  Maybe it makes sense to enforce this naming restriction just to help less sophisticated programmers (i.e. scientists).

Rik <rik5>
Project Administrator
Thu 18 Apr 2019 09:44:34 PM UTC, comment #1: 

I don't know why it would cause trouble.  Even something like the following seems like it should work.

classdef foobar
    function obj = foobar (...)
      obj.foobar = ...;

Inside methods, isn't it required to use obj.property to access properties?  If so, then I don't see a conflict between property names and the constructor (class) name.  It seems to me that you could even have a method that called the constructor to create another object of the same type without having a conflict.

Am I missing something?

John W. Eaton <jwe>
Project Administrator
Fri 22 Feb 2019 09:59:01 PM UTC, original submission:  

Matlab does not allow a property inside a class to have the same name as the class.  Octave does allow this.  Is there any significant architecture issue to allowing / disallowing this behavior?  In any case, I am just pointing it out.

Sample code in file testprop.m

classdef testprop

                testprop = 0;


Then execute

x = testprop

Rik <rik5>
Project Administrator


(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 jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.





    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-11 rik5 Severity3 - Normal 2 - Minor
    2019-02-22 rik5 Priority5 - Normal 3 - Low

    Back to the top

    Powered by Savane 3.10