bugGNU Octave - Bugs: bug #33064, Object does not seem to be cloned

 
 

bug #33064: Object does not seem to be cloned

Submitted by:  Dominik Schulz <realniki>
Submitted on:  Wed 13 Apr 2011 04:07:34 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 3.2.4Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 29 Feb 2012 05:30:32 PM UTC, comment #3:

The behavior did change from Octave-3.2.4 (no cloning) to Octave-3.4.0 (cloning).

I suppose the issue is still resolved for you since this is the behavior you were looking for and Octave now does this by default.

Rik <rik5>
Project Administrator
Wed 29 Feb 2012 09:04:36 AM UTC, comment #2:

Maybe it is me who has a problem of understanding the issue, but using Octave 3.6.0 (Gentoo Linux) I get the expected results (r1 == 951 and r2 == 987). So, changing the member 'a' via setparam() does not change the respective member in the other object.

Dominik Schulz <realniki>
Tue 28 Feb 2012 01:14:37 AM UTC, comment #1:

This is not a bug. The '=' operator implements only a shallow copy. If you want to implement a deep copy (or clone) you need to write the code for it into the class itself. The Matlab documentation has multiple articles on this. See http://www.mathworks.com/help/techdoc/matlab_prog/brtm8si.html as well as this one for a solution http://www.mathworks.com/matlabcentral/fileexchange/22965-clone-handle-object-using-matlab-oop

Rik <rik5>
Project Administrator
Wed 13 Apr 2011 04:07:34 PM UTC, original submission:

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:

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

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

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

Dominik Schulz <realniki>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by realniki (Submitted the item)
  • -unavailable- added by realniki
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 29 Feb 2012 05:30:32 PM UTCrik5StatusInvalid=>Fixed
    Tue 28 Feb 2012 01:14:37 AM UTCrik5StatusNone=>Invalid
      Open/ClosedOpen=>Closed
    Wed 13 Apr 2011 04:07:34 PM UTCrealnikiCarbon-Copy-=>Added realniki

    Back to the top


    Powered by Savane 3.1-cleanup1