[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Classdef test required on Matlab
From: |
fgnievinski |
Subject: |
Re: Classdef test required on Matlab |
Date: |
Sun, 19 Jan 2014 19:14:14 -0800 (PST) |
Michael Goffioul wrote
> On Sun, Jan 19, 2014 at 12:36 PM, Lukas Reichlin <
> lukas.reichlin.lists@
>> wrote:
>
>> On 19.01.2014, at 17:42, Michael Goffioul <
> michael.goffioul@
> >
>> wrote:
>>
>> > Could someone test the following in Matlab? Put all files into a single
>> dir, then run "runAll".
>> >
>> > Thanks,
>> > Michael.
>> >
>> >
> <clA.m>
> <clB.m>
> <clC.m>
> <runAll.m>
>>
>> Here you go :-) R2013a on a Mac.
>>
>> Cheers,
>> Lukas
>>
>> >> runAll
>> >>> calling aa.getPropFromA
>> >>> clA::subsref
>>
>> ans =
>>
>> 10
>>
>> >>> calling bb.getPropFromA
>> >>> clA::subsref
>>
>> ans =
>>
>> 10
>>
>> >>> calling bb.getPropFromB
>> >>> clA::subsref
>>
>> ans =
>>
>> 10
>>
>> >>> calling cc.getPropFromC
>> >>> clA::subsref
>>
>> ans =
>>
>> 10
>>
>> >>
>
>
> Thanks. However, this is rather unexpected. I was reading documentation
> about overloading subsref [1] and the documentation says that built-in
> subsref is always called from withing class methods. So unless I'm
> mis-reading the doc, the first case should at least not have called
> clA::subsref. This doesn't make sense...
>
> Michael.
>
>
> [1]
> http://www.mathworks.com/help/matlab/matlab_oop/indexed-reference-and-assignment.html#br09nsm
clA::subsref is being reached directly from runAll, not through method
getPropFromA.
modifying subsref as follows:
function y = subsref (this, S)
disp('>>> clA::subsref');
display(dbstack(1))
display(S)
y = this.prop;
end
shows that:
>>> calling aa.getPropFromA
>>> clA::subsref
file: 'runAll.m'
name: 'runAll'
line: 5
S =
type: '.'
subs: 'getPropFromA'
ans =
10
on the other hand, calling the method explicitly,
does NOT reach the overload subsref, as expected:
>> getPropFromA(aa)
ans =
10
--
View this message in context:
http://octave.1599824.n4.nabble.com/Classdef-test-required-on-Matlab-tp4661171p4661182.html
Sent from the Octave - Maintainers mailing list archive at Nabble.com.
Re: Classdef test required on Matlab, Steph Bredenhann, 2014/01/19