There is a problem with deeply places references (often objects) not being
full copy constructed but the reference is copied.
In order to change the behavior we would have to do a deep copy *everytime*
we copy a complex structure. This would be very bad performance wise so
except for thinking about it I don't have a quick answer. You can most
probably code around it (create a $a->clone() function which also copies
the object inside).
Andi
At 07:20 PM 3/6/2001 +0100, Roland wrote:
>Hello,
>consider following two classes:
>
> class TDynVars
> {
> var $vars;
> function set ($key, $val)
> {
> $this->vars[$key] = $val;
> }
> }
>
> class TRequest
> {
> var $eventData;
> function TRequest ()
> {
> $this->eventData = new TDynVars;
> }
> }
>
>and two programs, A and B.
>program A:
>
> $r1 = new TRequest;
> $r1->eventData->vars[0]=1;
> $r2 = $r1;
> $r2->eventData->vars[0]=2;
> print($r1->eventData->vars[0]);
>
>output of program A should be "1" and is "1", it is OK.
>
>program B:
>
> $r1 = new TRequest;
> $r1->eventData->set(0,1);
> $r2 = $r1;
> $r2->eventData->vars[0]=2;
> print($r1->eventData->vars[0]);
>
>output of program B should be obviously "1" and is "2", it is NOT OK.
>
>Why $r2 changes data of $r1 if $r2 is $r1's copy by value not reference?
>
>Why this faulty behaviour is dependent on indirect access using member
>function use instead of direct acces?
>
>Note: The program B on PHP3.0.8 runs correctly, but not on PHP4.0.4.
>
>Thank you for solving this fundamental problem.
>Roland Divin
>
>
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]