Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:22998 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44987 invoked by uid 1010); 27 Apr 2006 20:27:53 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 44972 invoked from network); 27 Apr 2006 20:27:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Apr 2006 20:27:52 -0000 X-PHP-List-Original-Sender: bu@orbitel.bg X-Host-Fingerprint: 195.24.32.29 vmail-1.orbitel.bg Linux 2.4/2.6 Received: from ([195.24.32.29:35651] helo=vmail-1.orbitel.bg) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 61/D0-11022-74921544 for ; Thu, 27 Apr 2006 16:27:52 -0400 Received: from localhost (mailprotection [10.0.0.2]) by vmail-1.orbitel.bg (Postfix) with ESMTP id 5706D12D6E for ; Thu, 27 Apr 2006 23:27:47 +0300 (EEST) Received: from vmail-1.orbitel.bg ([10.0.0.1]) by localhost (sof-rv1.orbitel.bg [10.0.0.2]) (amavisd-new, port 10024) with ESMTP id 21924-49 for ; Thu, 27 Apr 2006 23:27:22 +0300 (EEST) Received: from [192.168.16.151] (unknown [85.187.217.172]) by vmail-1.orbitel.bg (Postfix) with ESMTP id 7C24112CE8 for ; Thu, 27 Apr 2006 23:27:46 +0300 (EEST) Reply-To: bu@orbitel.bg To: internals@lists.php.net Date: Thu, 27 Apr 2006 23:27:56 +0300 User-Agent: KMail/1.9.1 References: <444FF5CD.2010805@dealnews.com> <444FF716.6070201@lerdorf.com> <44512305.90207@pobox.com> In-Reply-To: <44512305.90207@pobox.com> X-Face: "c4tG*FY$8"*gUsm0B.S%v5*[!@-f4J`V@OaocG0\)x]-G`$Hy1#tWj~4VvL@6s X-Virus-Scanned: by amavisd-new at orbitel.bg Subject: Re: [PHP-DEV] Passing functions to function by reference From: bu@orbitel.bg (Petar Nedyalkov) --nextPart1274398.chqT0D6dcP Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thursday 27 April 2006 23:01, Brion Vibber wrote: > Rasmus Lerdorf wrote: > >> PHP 5.0 broke this. There was a fatal error on the array_shift that > >> only variables could be passed by reference. There was a good > >> argument for it. So, we started migrating our code. > >> > >> Well, seems this works in 5.1. So, my question is, was it an > >> intentional "fix" or will this break again and we need to continue to > >> watch for this? > > > > In 5.1 this now throws an E_STRICT instead of a warning. It is still a > > bad idea to pass a tempvar by reference, so yes, you should strive to > > write E_STRICT clean code. > > Stupid question: why is it a bad idea? Check the mailing-list archive - there was a long discussion on this topic= =20 some 4, 5 months ago. > > I would expect these to be equivalent for all intents and purposes: > > func_taking_reference(some_func()); > > and > > $temp =3D some_func(); > func_taking_reference($temp); > > where $temp is never used again and quickly passes out of scope. > > Is there some reason that they are not considered equivalent, or that they > cannot or should not be made equivalent? Yes, of course :-) Nothing happens by chance here. > > I seem to remember a reason being quoted for all these reference-related > changes something like it can cause memory corruption. But that would > appear to be an implementation bug, not an essential difficulty, as if it > were really *memory corruption* I can't imagine it being turned back on in > 5.1. :) > > -- brion vibber (brion @ pobox.com / brion @ wikimedia.org) =2D-=20 Cyberly yours, Petar Nedyalkov Devoted Orbitel Fan :-) PGP ID: 7AE45436 PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436 --nextPart1274398.chqT0D6dcP Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQBEUSlQLT98C3rkVDYRAnv6AJ94GyDCA74tx8MH+RyWMJy05FtJEgCfTkc5 hTeB0dNaKDWJm7TaUdFEzIM= =3n/l -----END PGP SIGNATURE----- --nextPart1274398.chqT0D6dcP--