Re: PHP 4.0 Bug #2755 Updated: new Object() scribbles on old references

From: Date: Mon, 22 Nov 1999 19:19:24 +0000
Subject: Re: PHP 4.0 Bug #2755 Updated: new Object() scribbles on old references
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-12931@lists.php.net to get a copy of this message
This seems weird to me. How do you decide when a discarded reference does and does not touch the variable its pointing to? e.g. function thing(&$var) { $x=&$var; return $x; } $y=1; $z=thing($y); $y=0; If in thing() $x and $var are bound as tightly as you say, how do you decide not to discard $var (or rather, $y) when the function exits? And since this obviously doesn't happen, there must be a way of making the mechanism available. A function unbind($var) would be handy, better would be to unbind a variable when it is assigned using new. I don't really care if I have to encapsulate things in objects in order to be able to use first-class references, but I do really need those references. What happens if I do $a=1; $b=2; $c=&$a; $c=&$b; Are $a,$b and $c now all references to the same variable? Duncan On Mon, 22 Nov 1999, you wrote: > ID: 2755 > Updated by: zeev > Reported By: duncan@emarketeers.com > Status: Closed > Bug Type: Scripting Engine problem > Assigned To: > Comments: > > Your understanding of the semantics is wrong. > When you write: > $y=&$x; > from that point onward, $y and $x are the same thing - nothing can unbind them. When you > assign a new object into > $x, it's identical to assigning the object into $y; Both > $x and $y will be pointing to the same value, be it a string, an array, or a newly created > object. > > Full Bug description available at: > http://bugs.php.net/version4/?id=2755 -- -------------------------------------------------------------------- Duncan McIntyre Director Emarketeers Ltd Priory Gate, Priory Road Dunstable, Beds. LU5 4HR England Duncan@Emarketeers.com (+44) 1582 534 324 - Office (+44) 7957 136 369 - Mobile

« previous php.dev (#12931) next »