At 01:45 12/04/2002, brad lafountain wrote:
>I really don't think that is the problem...
>
>Im pretty sure i know exactly whats going on.. if you look at the zend_execute
>it automatically adds a is_ref = 1; and a ref_count++; for all method calls(
>the comment next to this line says /* for $this ref */.. this works normally
>just becuase a normal method call is a IS_TMP_VAR..

Hmm, how do you figure that?  It invoked on IS_VAR all the same, $this is a 
variable...

>  but in the case of a
>object's member it is a IS_VAR.. so the ref_count and is_ref gets kept right
>along with the instance of the object.. so when you try and copy it with
>  $a_copy = $a;
>the ref gets copyed along with it so changing anything in
>$a_copy->some_object_you_have_called_a_method_on; the change will be reflected
>in $a and $a_copy.
>
>
>This is defintly a BUG in engine1 and i think it should be addressed.

It's by design, and can't be addressed in v1.  It'll be solved 
automatically in v2...
The engine turns each object into is_ref when you invoke a method on that 
object.  The reason is that it links the outer object with $this inside the 
method context, and it does that using the standard is_ref infrastructure.

>this bug only happens when you invoke a method from a instance of an objects
>member that is an object.

For the same reason that $foo = new foo;  $foo->bar() will result in $foo 
having is_ref set, the same happens when you use object members which are 
object themselves.  It does have an annoying side effect, when you copy the 
other object around, but as mentioned, it cannot be solved in v1.  In v2, 
it should work out of the box, because of the special treatment of $this, 
and the reference based system.

Zeev


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to