[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #32060] Accessing OO properties in subfunction
From: |
Guillaume |
Subject: |
[Octave-bug-tracker] [bug #32060] Accessing OO properties in subfunction of a private class method |
Date: |
Wed, 05 Jan 2011 15:50:57 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.2.13) Gecko/20101203 SUSE/3.6.13-0.2.1 Firefox/3.6.13 |
URL:
<http://savannah.gnu.org/bugs/?32060>
Summary: Accessing OO properties in subfunction of a private
class method
Project: GNU Octave
Submitted by: gyom
Submitted on: Wed Jan 5 15:50:57 2011
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Guillaume
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: GNU/Linux
_______________________________________________________
Details:
Accessing fields of an object should be done directly from within a method
(ie not calling subsref/subsasgn): while this is the case for a public class
method and for a private class method (see:
https://savannah.gnu.org/bugs/?30909), it is not for a subfunction of a
private class method.
This can be reproduced with the following code:
==================== @testclass/testclass.m ====================
function obj = testclass(varargin)
obj = struct('public',1, 'private',0);
obj = class(obj,'testclass');
==================== @testclass/subsref.m ====================
function dat = subsref(obj,subs)
switch subs.type
case '.'
switch subs.subs
case 'public'
%dat = obj.param;
dat = param(obj);
otherwise
error('err');
end
otherwise
error('err');
end
==================== @testclass/private/param.m ====================
function dat = param(obj)
%dat = obj.public; % direct access => works
dat = param2(obj); % => subfunction calls subsref => crash
function dat = param2(obj)
dat = obj.public; % calls subsref...
========================================
octave> a = testclass;
octave> a.public
results in an infinite loop param<->subsref in Octave, while this works as
expected in MATLAB.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?32060>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #32060] Accessing OO properties in subfunction of a private class method,
Guillaume <=