Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24941 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59664 invoked by uid 1010); 24 Jul 2006 17:53:16 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 59648 invoked from network); 24 Jul 2006 17:53:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jul 2006 17:53:16 -0000 X-PHP-List-Original-Sender: truth@proposaltech.com X-Host-Fingerprint: 68.142.198.210 smtp111.sbc.mail.mud.yahoo.com Received: from ([68.142.198.210:33976] helo=smtp111.sbc.mail.mud.yahoo.com) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id FA/E2-04178-A0905C44 for ; Mon, 24 Jul 2006 13:53:16 -0400 Received: (qmail 55057 invoked from network); 24 Jul 2006 17:53:12 -0000 Received: from unknown (HELO ?192.168.2.106?) (toddruth@sbcglobal.net@71.137.129.173 with login) by smtp111.sbc.mail.mud.yahoo.com with SMTP; 24 Jul 2006 17:53:11 -0000 Reply-To: truth@proposaltech.com To: internals@lists.php.net In-Reply-To: <200607241916.27024.johannes@php.net> References: <44C4ECC6.8080401@kaluma.com> <200607241916.27024.johannes@php.net> Content-Type: text/plain Date: Mon, 24 Jul 2006 10:53:27 -0700 Message-ID: <1153763607.30382.184.camel@notebook.local> Mime-Version: 1.0 X-Mailer: Evolution 2.4.0 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Pass by reference (5.1.1 vs 5.1.2) From: truth@proposaltech.com (Todd Ruth) It looks like http://www.php.net/manual/en/language.operators.assignment.php could use a bit of updating. A paragraph about php 5 or a link to the semantics changes for php 5 would help newbies. The text about php4 says there is copy on assignment, which implies a performance hit for using = instead of =&, but I believe "copy on change" is more accurate. It wouldn't hurt to explicitly say that "=" is generally better than "=&" (unless you really need an alias). A user comment has been there unchallenged for over 2 years saying you can pass an assignment as a reference to a function, so it isn't surprising that someone considered the 5.1.1 to 5.1.2 change an issue. (Not that a user comment should bind the php devs, but when the comment goes unchallenged, it can lead to false impressions.) Perhaps some text explaining the assignment returns an r-value would be helpful. (If people understand "($x = 1) = 2;" shouldn't work, they might understand that passing "$x=1" to a function by reference shouldn't affect $x. (or should "($x = 1) = 2;" work and 5.1.2 had a real bug?)) I have to say the documentation for php is completely awesome and is a major factor in our company using the language. I just point out the above to help; it isn't a complaint. BTW, I disagree with the post below that indicates the issue is the order of calling. There is no way to call a function before doing the work in the argument list. If I call f(1+2), I can be sure the computation to get 3 will be performed _before_ calling f. The issue with f($p=array()) is that "$p=array()" is an r-value. - Todd On Mon, 2006-07-24 at 19:16 +0200, Johannes Schlueter wrote: > Hi, > > On Monday 24 July 2006 17:52, Rishad Omar wrote: > > getArray($p = array()); > > Here you are relying on undefined behavior. It is not defined wether $p = > array() or the function call getarray($p) should be executed first so the > order might always change. > > You should always use the two lines > $p = array(); > getArray($p); > to be safe. > > johannes > -- Todd Ruth