I'm trying to understand part of the code in tree_index_expression::lvalue() and I was hoping you could give me a hint.
classdef ClassA
properties
prop;
end
methods
function obj = ClassA()
disp('ClassA constructor');
end
function obj = set.prop (obj, value)
disp ('ClassA.set.prop');
obj.prop = value;
end
function value = get.prop (obj)
disp ('ClassA.get.prop');
value = obj.prop;
end
end
end
Using the current classdef branch, if you type the following at octave prompt:
x = ClassA()
x.prop.a = 10
you'll see the following debug lines (I'm only printing the relevant lines):
ClassA.get.prop
ClassA.get.prop
ClassA.set.prop
In other words, the get access method is called twice. This is unexpected; according to Matlab documentation [1], it should only be called once.
When tracing the code, I found out that the first call to the get access method is due to the fact that tree_index_expression::lvalue calls subsref (around line 462). But I can't figure out why or what's the use case. I know that part of the code has been heavily modified by Jaroslav, but maybe you have some insight.
When looking at the history of changes for that part of the code, it looks like the "subsref" call would only occur in case of magic end or magic colon. But that restriction eventually disappeared.
Michael.