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

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

[Octave-bug-tracker] [bug #54028] copy of non-handle class instance is n


From: Rik
Subject: [Octave-bug-tracker] [bug #54028] copy of non-handle class instance is not deep
Date: Fri, 29 Jun 2018 16:38:34 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0

Follow-up Comment #4, bug #54028 (project octave):

Adding jwe to the CC list since this is probably going to require his
understanding of when two symbol references to the same underlying variable
are split (Copy-on-Write semantics).

I think I have a simpler example that uses only the object a (a.m).  In this
case, a single object that is changed correctly invokes COW semantics and the
variables are split as shown below.


octave:52> x.array = a
x =

  scalar structure containing the fields:

    array =

    <object a>


octave:53> y = x
y =

  scalar structure containing the fields:

    array =

    <object a>


octave:54> x.array.ap
ans =  1
octave:55> y.array.ap = 5;
octave:56> x.array.ap
ans =  1
octave:57> y.array.ap
ans =  5


However, the struct variable array is an object array then this no longer
works.


octave:58> clear x y
octave:59> x.array = a
x =

  scalar structure containing the fields:

    array =

    <object a>


octave:60> x.array(2) = a
x =

  scalar structure containing the fields:

    array =

    <object array a>


octave:61> y = x;
octave:62> x.array(1).ap
ans =  1
octave:63> y.array(1).ap = 5;
octave:64> x.array(1).ap
ans =  5
octave:65> diary off


It would appear that the real issue is object arrays.  I can make the example
even simpler by removing the struct.


octave:9> x = a
x =

<object a>

octave:10> x(2) = a
x =

<object array a>

octave:11> y = x
y =

<object array a>

octave:12> x(1).ap
ans =  1
octave:13> y(1).ap = 5
y =

<object array a>

octave:14> x(1).ap
ans =  5




    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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