Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19046 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76798 invoked by uid 1010); 16 Sep 2005 12:21:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 76783 invoked from network); 16 Sep 2005 12:21:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2005 12:21:26 -0000 X-Host-Fingerprint: 82.94.239.5 jdi.jdi-ict.nl Linux 2.5 (sometimes 2.4) (4) Received: from ([82.94.239.5:34439] helo=jdi.jdi-ict.nl) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id D2/9B-43379-4C8BA234 for ; Fri, 16 Sep 2005 08:21:25 -0400 Received: from localhost (localhost [127.0.0.1]) by jdi.jdi-ict.nl (8.12.11/8.12.11) with ESMTP id j8GCLMcW001557; Fri, 16 Sep 2005 14:21:22 +0200 Received: from localhost (localhost [127.0.0.1]) by jdi.jdi-ict.nl (8.12.11/8.12.11) with ESMTP id j8GCLGM6001538; Fri, 16 Sep 2005 14:21:16 +0200 Date: Fri, 16 Sep 2005 08:21:16 -0400 (EDT) X-X-Sender: derick@localhost To: Todd Ruth cc: internals@lists.php.net In-Reply-To: <1126847313.15244.18.camel@notebook> Message-ID: References: <08.98.43379.6081A234@pb1.pair.com> <1126847313.15244.18.camel@notebook> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at jdi-ict.nl Subject: Re: [PHP-DEV] Re: Reference handling change and PHP 4.4.0 From: derick@php.net (Derick Rethans) 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