bugGNU Octave - Bugs: bug #46892, subsref for OO @class failed to be...

 
 

bug #46892: subsref for OO @class failed to be called within method function.

Submitted by:  Rik <rik5>
Submitted on:  Wed 13 Jan 2016 11:55:36 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 14 Jan 2016 04:16:44 PM UTC, comment #3:

@Oliver: Thanks for pointing out the futility of having indexing operators call subsref within a method function itself. I only came across some of these issues because I overhauled the documentation on Object Oriented programming (http://hg.savannah.gnu.org/hgweb/octave/rev/220506787b93) and found that some of the code would not work.

In this case, the clearer solution was to avoid subsref entirely and just call polyval. See this cset http://hg.savannah.gnu.org/hgweb/octave/rev/9b3149cd486b.

Rik <rik5>
Project Administrator
Thu 14 Jan 2016 06:34:32 AM UTC, comment #2:

… as always I have forgotten the curly braces.

````
idx = struct ("type", "()", "subs", {x})
plot (x, subsref (p, idx), varargin{:});
````

Oliver Heimlich <oheim>
Thu 14 Jan 2016 06:32:25 AM UTC, comment #1:

It is the expected behaviour that `subsref` and `subsasgn` with operator syntax do not use overloaded methods. Otherwise it would not be possible to access the object's internal data anymore.

So the plot.m method should be fixed and use something like this:

````
idx = struct ("type", "()", "subs", x)
plot (x, subsref (p, idx), varargin{:});

````

Oliver Heimlich <oheim>
Wed 13 Jan 2016 11:55:36 PM UTC, original submission:

The failing code is taken from examples/code/@polynomial/plot.m.

The code is

The code makes use of overloading for the subsref function so that p(x) calculates the value of the polynomial at the points x. Unfortunately, the overloaded subsref is not called and it is treated as normal indexing which then fails because some of the x values are not integers.

Rik <rik5>
Project Administrator

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by oheim (Posted a comment)
  • -unavailable- added by rik5 (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 14 Jan 2016 04:16:44 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1