octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #33064] Object does not seem to be cloned


From: Dominik Schulz
Subject: [Octave-bug-tracker] [bug #33064] Object does not seem to be cloned
Date: Wed, 13 Apr 2011 16:07:35 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:2.0) Gecko/20100101 Firefox/4.0

URL:
  <http://savannah.gnu.org/bugs/?33064>

                 Summary: Object does not seem to be cloned
                 Project: GNU Octave
            Submitted by: realniki
            Submitted on: Mi 13 Apr 2011 16:07:34 GMT
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.2.4
        Operating System: GNU/Linux

    _______________________________________________________

Details:

I encountered a strange behavior on my Kubuntu 10.10 workstation with GNU
Octave 3.2.4 when using classes as described in the Octave documentation.

Let's say I have a class 'testclass1' in directory @testclass1 which provides
a member 'a' like this:


function y = testclass1(a)
        y.a = a;
        y = class(y, "testclass1");
endfunction



function self = setparam(self, a)
        self.a = a;
endfunction



function a = getparam(self)
        a = self.a;
endfunction


Now I derive a mainly  empty class called 'testclass2' (directory @testclass2)
from 'testclass1' like this:


function y = testclass2()
        y = struct;
        super = @testclass1(951);
        y = class(y, "testclass2", super);
endfunction


Now I am using 'testclass2' in a code like this


c_1 = testclass2(); 
c_2 = c_1; 
c_2 = setparam(c_2, 987);
r1= getparam(c_1),
r2 = getparam(c_2),


The result is that r1 and r2 are both equal to 987, which I assume to be wrong
when r2 should be a clone of r1. Only the value of c_2 should be modified.
Actually it makes no difference whether one modifies c_1 or c_2. It always
changes both objects. Thus, for me both objects seem to be the same.
  Strangely the problem does not occur when the base class testclass1 is empty
and all members ('a', setparam(), getparam()) are implemented in the derived
class testclass2.


Thank you




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?33064>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]