Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37554 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21943 invoked from network); 8 May 2008 21:44:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 May 2008 21:44:31 -0000 Authentication-Results: pb1.pair.com header.from=truth@proposaltech.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=truth@proposaltech.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain proposaltech.com from 69.147.64.89 cause and error) X-PHP-List-Original-Sender: truth@proposaltech.com X-Host-Fingerprint: 69.147.64.89 smtp116.sbc.mail.sp1.yahoo.com FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from [69.147.64.89] ([69.147.64.89:21000] helo=smtp116.sbc.mail.sp1.yahoo.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0F/F5-23700-E3473284 for ; Thu, 08 May 2008 17:44:31 -0400 Received: (qmail 2525 invoked from network); 8 May 2008 21:44:27 -0000 Received: from unknown (HELO ?192.168.2.101?) (toddruth@sbcglobal.net@69.236.135.99 with login) by smtp116.sbc.mail.sp1.yahoo.com with SMTP; 8 May 2008 21:44:26 -0000 X-YMail-OSG: prNsenMVM1m0l8lprT_iyh.sKawDpjsuoOrzw781vVWzgCtghlWl71K7c8Q11VLYbvLPNBBUdMb.3BQUXa9JU2KUve5qtycGRn1HAMk9NjByRVz7lLZnAIEKaGLoaHW_9w-- X-Yahoo-Newman-Property: ymail-3 Reply-To: truth@proposaltech.com To: internals In-Reply-To: <7f3ed2c30805081358r4741711egdb22bd402846965f@mail.gmail.com> References: <021601c8b141$bbf64a50$4001a8c0@foxbox> <1210277285.8421.23.camel@inspiron.local> <7f3ed2c30805081358r4741711egdb22bd402846965f@mail.gmail.com> Content-Type: text/plain Date: Thu, 08 May 2008 14:44:20 -0700 Message-ID: <1210283060.8421.42.camel@inspiron.local> Mime-Version: 1.0 X-Mailer: Evolution 2.8.2 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] allow_call_time_pass_reference From: truth@proposaltech.com (Todd Ruth) On Thu, 2008-05-08 at 22:58 +0200, Hannes Magnusson wrote: > On Thu, May 8, 2008 at 10:08 PM, Todd Ruth wrote: > > On Thu, 2008-05-08 at 20:28 +0100, Steph Fox wrote: > >> ... > >> Does anyone have a good reason for keeping it switched on by default in PHP > >> 5.3? Like, would switching it off by default break a lot of existing code, > >> given that most users are a bit beyond PHP 3 now? > > > > Well, I can at least comment on how it is used in the code that > > I inherited. First it must be noted that the following throws > > a fatal error: > > > > function f(&$x=5) { .... > > No it doesn't. > That line does however not work exactly as you would expect.. Quite right. I should have said "leads to fatal errors". It doesn't throw a fatal error on it's own, but if you have old code that you must maintain in which a function is sometimes called as f(), sometimes called as f(10), and sometimes called as f(&$y), trying to "fix it" with the declaration above will lead to fatal errors for the f(10) calls. (The defaulting part isn't the problem for that case; it's using a non-variable when a reference is needed that leads to the fatal error.) BTW, in php4, there was an incentive to use call-time pass-by-reference. Calling f(g()) was a very bad thing if f always accepted its parameter by reference. There are a number of other similar cases. In php5 (and the last few releases of php4), it's still bad, but at least memory doesn't get corrupted now. In contrast, not declaring f to accept its parameter by reference and instead using call-time pass-by-reference was (and is) safe (though deprecated). - Todd