[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
error using subsref and oop
From: |
John W. Eaton |
Subject: |
error using subsref and oop |
Date: |
Mon, 27 Apr 2009 14:24:36 -0400 |
On 27-Apr-2009, Bertrand Roessli wrote:
| I used the new oop feature in Octave that I am trying to
| learn.
|
| For this function (found on the web) in the directory @date
|
| function [obj] = date(minute, hour, day, month, year)
| % constructor saved in file date.m
|
| obj = struct;
| obj.minute = []; % leave blank for whatever reason
| obj.hour = hour;
| obj.day = day;
| obj.month = month;
| obj.year = year;
|
| obj = class(obj,'date');
| end
|
| I can overload the operator "." by writing another function
|
| function [value] = subsref(obj, S)
|
| idx.type=S.type;
| idx.subs={S.subs};
|
|
| switch idx.type
| case '.'
| switch idx.subs{:}
| case 'minute'
| value=obj.minute;
| case 'hour'
| value=obj.hour;
| ...
| endswitch
| endswitch
|
| end
|
| which works fine
|
| octave:2> min=obj.minute;
| octave:3> min
| min = [](0x0)
| octave:4> min=obj.hour;
| octave:5> min
| min = 2
|
| However, using
|
| builtin('subsref', obj, idx)
|
| in
|
| function [value] = subsref(obj, S)
|
| idx.type=S.type;
| idx.subs={S.subs};
|
| value = builtin('subsref', obj, idx);
|
| end
|
| results in an error in octave-3.1.55
|
| octave:9> obj=date(12,2,3,11,2008);
| octave:10> min=obj.hour;
| error: max_recursion_limit exceeded
I checked in the following change.
http://hg.savannah.gnu.org/hgweb/octave/rev/b2b8ed43b922
Please report bugs to the address@hidden list.
jwe