[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #58953] Error with 'end' in index expression w
From: |
Fernando |
Subject: |
[Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls |
Date: |
Fri, 18 Sep 2020 12:16:53 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0 |
Follow-up Comment #41, bug #58953 (project octave):
We are very close. You have solved two problems:
- Incorrect dispatch for 'end' in cases like obj.data(end).
- Builtin 'end' ignores arguments when called from user code
There is still a third problem, which I had not provided a test for
- Incorrect dispatch for 'subsref' when used to obtain the object on which
'end' is to be applied.
To show the third problem, I defined the following class, where subsref
transforms obj.data to obj.data_
classdef myclass3 < handle
properties
data_
end
methods
function obj = myclass3(data)
obj.data_ = data;
end
function r = subsref(obj,S)
fprintf('-----------------\n')
S.type
S.subs
fprintf('-----------------\n')
if strcmp(S(1).type,'.') && strcmp(S(1).subs,'data')
S(1).subs='data_';
end
r = builtin('subsref',obj,S);
end
function r = end(obj,k,n)
fprintf('''end'' called with index=%d of %d\n',k,n);
r = builtin('end',obj.data,k,n)-1;
end
end
end
then in Matlab:
>> obj=myclass3(1:5)
obj =
myclass3 with properties:
data_: [1 2 3 4 5]
>> obj.data(end)
-----------------
ans =
'.'
ans =
'data'
-----------------
-----------------
ans =
'.'
ans =
'()'
ans =
'data'
ans =
1×1 cell array
{[5]}
-----------------
ans =
5
and in Octave:
octave:33> obj.data(end)
error: subsref: unknown method or property: data
What is happening is that in order to evaluate 'end', we must first evaluate
'obj.data', which should be done using the custom subsref, not the builtin
subsref.
Sure, I can provide help writing some tests for problems like those three.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?58953>
_______________________________________________
Mensaje enviado vía Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, (continued)
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, John W. Eaton, 2020/09/14
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, John W. Eaton, 2020/09/16
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Guillaume, 2020/09/16
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, John W. Eaton, 2020/09/16
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Fernando, 2020/09/16
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Fernando, 2020/09/17
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, John W. Eaton, 2020/09/17
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Fernando, 2020/09/18
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Guillaume, 2020/09/18
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, John W. Eaton, 2020/09/18
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls,
Fernando <=
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Guillaume, 2020/09/18
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, John W. Eaton, 2020/09/19
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Fernando, 2020/09/19
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Guillaume, 2020/09/19
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Guillaume, 2020/09/19
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Fernando, 2020/09/19
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Fernando, 2020/09/19
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Guillaume, 2020/09/20
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, Fernando, 2020/09/20
- [Octave-bug-tracker] [bug #58953] Error with 'end' in index expression with nested function calls, John W. Eaton, 2020/09/21