[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: FYI: subasgn argument optimization
From: |
Jaroslav Hajek |
Subject: |
Re: FYI: subasgn argument optimization |
Date: |
Sat, 15 Aug 2009 09:04:02 +0200 |
On Fri, Aug 14, 2009 at 11:05 PM, Judd Storrs<address@hidden> wrote:
> On Fri, Aug 14, 2009 at 1:05 PM, Jaroslav Hajek <address@hidden> wrote:
>>
>> OK, here are some:
>>
>> * A class is constructed from a struct. Can the struct be
>> multidimensional? (if the answer is no, then there is no need to read
>> further).
>
> Apparently, yes. But, it seems to come out as an array of objects.
>
> @foo/foo.m:
> function obj = foo()
> obj(10).data = 1 ;
> obj = class(obj,'foo') ;
> end
>
> Then in matlab (I edited the whitespace):
>
>>> a = foo()
> a = foo object: 1-by-10
>>> b = a(1)
> b = foo object: 1-by-1
>>>
>
> Now I created
>
> @bar/bar.m
> function obj = foo()
> obj.data = 1 ;
>
> obj = class(obj,'foo') ;
> end
>
>
>>> b = bar()
> ??? Error using ==> class
> Size of struct array being made into an object and the parent objects must
> be consistent.
>
> Error in ==> bar.bar at 4
> obj = class(obj,'bar',parent) ;
>
>>>
>
That just adds more confusion. SO, if I want to do
class (obj, 'bar', parent), and obj is m-by-n, what dimensions should
parent be? m-by-n.
And what does obj.parent return, then?
Also, does Matlab really auto-forward the field references to parent
classes? I can't find that anywhere in the Matlab docs. For instance,
if a class bar inherits from foo, which has a field xx, does this.xx
really work inside bar methods, or must one do this.foo.xx?
Personally, I really doubt that the old model is much used for
inheritance, so I'd vote to keep the support at minimal level. The
auto-forwarding of the fields is what complicates the implementation
the most.
--
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- FYI: subasgn argument optimization, Jaroslav Hajek, 2009/08/13
- Re: FYI: subasgn argument optimization, Jaroslav Hajek, 2009/08/17
- Re: FYI: subasgn argument optimization, John W. Eaton, 2009/08/18
- Re: FYI: subasgn argument optimization, Robert T. Short, 2009/08/18
- Re: FYI: subasgn argument optimization, Jaroslav Hajek, 2009/08/18
Re: FYI: subasgn argument optimization, Robert T. Short, 2009/08/13
FYI: subasgn argument optimization, John W. Eaton, 2009/08/14