Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19058 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17985 invoked by uid 1010); 16 Sep 2005 15:27:38 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 17970 invoked from network); 16 Sep 2005 15:27:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2005 15:27:38 -0000 X-Host-Fingerprint: 68.142.198.212 smtp113.sbc.mail.mud.yahoo.com Received: from ([68.142.198.212:35834] helo=smtp113.sbc.mail.mud.yahoo.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 96/01-43379-964EA234 for ; Fri, 16 Sep 2005 11:27:37 -0400 Received: (qmail 85246 invoked from network); 16 Sep 2005 15:27:34 -0000 Received: from unknown (HELO 192.168.2.101) (jabouillei@71.136.47.251 with plain) by smtp113.sbc.mail.mud.yahoo.com with SMTP; 16 Sep 2005 15:27:33 -0000 Reply-To: truth@proposaltech.com To: internals@lists.php.net In-Reply-To: References: <08.98.43379.6081A234@pb1.pair.com> <1126847313.15244.18.camel@notebook> Content-Type: text/plain Date: Fri, 16 Sep 2005 08:27:25 -0700 Message-ID: <1126884445.15244.37.camel@notebook> Mime-Version: 1.0 X-Mailer: Evolution 2.0.1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Reference handling change and PHP 4.4.0 From: truth@proposaltech.com (Todd Ruth) Wasn't part of the "negotiation" when 4.4 was created that the behavior would be the same as 4.3 (excluding anything that happened because of a memory corruption)? (I'm not counting the notices as behavior.) I don't see how it can be argued that "$y =& ..." leaving $y connected to it's old buddies can be considered correct. I see why $y should not be tied to the rvalue if the rvalue is not suitable for being used as a reference, but that doesn't change the fact that this code clearly indicates $y should be detached from anything it was formerly attached to. Wouldn't the php philosophy indicate $y should be unset before being assigned by value in this case? (and after all, doing that preserves BC!) Please elaborate on the idea that the new behavior is correct. BTW, when you say "This has bitten me too a couple of times", are you saying that you were aware of a BC break beyond memory corruption and didn't mention it? Thanks, Todd On Fri, 2005-09-16 at 08:21 -0400, Derick Rethans wrote: > On Thu, 15 Sep 2005, Todd Ruth wrote: > > > Aha! That was the inspiration I needed to get the right > > combination of "&"s. The following bit of code behaves > > differently under 4.3 vs 4.4: > > > > > function f(&$a) { return $a; } > > $x = array('a','b','c'); > > foreach (array_keys($x) as $k) { > > // I think the following line disconnects $y in 4.3 > > // but leaves $y connected in 4.4 > > $y =& f($x[$k]); > > $z[] =& $y; > > } > > var_dump($x); > > var_dump($z); > > ?> > > > > My guess would be that in 4.3 the engine tries to do the > > reference even though it may be dangerous. That would > > "disconnect" $y from the previous $z[]. 4.4 knows the > > reference is impossible and leaves $y connected to the > > previous $z[]. Is that analysis correct, engine gurus? > > Yes, it is. This has bitten me too a couple of times. But ofcourse, the > new behavior *is* the correct one. > > Derick > > -- > Derick Rethans > http://derickrethans.nl | http://ez.no | http://xdebug.org >