[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: arrays of objects and builtin methods
From: |
Ben Abbott |
Subject: |
Re: arrays of objects and builtin methods |
Date: |
Mon, 19 Dec 2011 12:34:46 -0500 |
On Dec 19, 2011, at 10:59 AM, J.J.Green wrote:
> Hi all
>
> Consider the following trivial class
>
> @myobj/myobj.m
>
> function f = myobj(str)
> f.name = str;
> f = class(f,'myobj');
>
> @myobj/display.m
>
> function display(f)
> fprintf('%s\n',f.name);
>
> @myobj/transpose.m
>
> function f = transpose(g)
> % do interesting things with input ...
> f = builtin('transpose',g);
>
> Now, lets make an array of these ...
>
> GNU Octave, version 3.5.90+
> Copyright (C) 2011 John W. Eaton and others.
> :
>
> octave:1> p = myobj('foo')
> foo
> octave:2> q = myobj('bar')
> bar
> octave:3> a = [p q]
> foo
> bar
> octave:4> size(a)
> ans =
>
> 1 2
>
> octave:5> class(a)
> ans = myobj
> octave:6> b = a.'
> error: ../@myobj/transpose.m at line 3, column 3
> error: ../@myobj/transpose.m at line 3, column 3
> :
> (and lots more of these)
>
> It seems that the builtin array transpose is not "seen"
> in the overloaded transpose method for the object, so it
> calls itself again and again until some kind of recursion
> depth is exceeded.
>
> The same code runs fine on Matlab
>
>
> < M A T L A B (R) >
> Copyright 1984-2011 The MathWorks, Inc.
> R2011b (7.13.0.564) 64-bit (glnxa64)
> August 13, 2011
>
>>> p = myobj('foo')
> foo
>>> q = myobj('bar')
> bar
>>> a = [p q]
> foo
> bar
>>> size(a)
>
> ans =
>
> 1 2
>
>>> b = a.'
> foo
> bar
>>> size(b)
>
> ans =
>
> 2 1
>
> Similar problems arise with other array methods (eg vertcat)
>
> Any ideas? Possible workarounds?
>
> Thanks in advance
>
> Jim
Looks like a bug.
Please file a report in the tacker.
https://savannah.gnu.org/bugs/?group=octave
Ben